diff --git a/.github/actions/setup-repo/action.yml b/.github/actions/setup-repo/action.yml new file mode 100644 index 0000000..1932a67 --- /dev/null +++ b/.github/actions/setup-repo/action.yml @@ -0,0 +1,35 @@ +name: Setup repo +description: Runs all steps to setup the repo (install node_modules, build, etc...) +inputs: + registry-token: + description: 'PAT to access registries' +runs: + using: 'composite' + steps: + - name: Get yarn cache directory path + id: yarn-cache-dir-path + shell: bash + run: | + echo "::set-output name=dir::$(yarn cache dir)" + echo "::set-output name=version::$(yarn -v)" + + - uses: actions/setup-node@v3 + with: + node-version: '20' + + - uses: actions/cache@v2 + id: yarn-cache + with: + path: | + **/node_modules + ${{ steps.yarn-cache-dir-path.outputs.dir }} + + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + shell: bash + run: echo "//npm.pkg.github.com/:_authToken=$GH_REGISTRY_ACCESS_TOKEN" >> .npmrc && yarn install --frozen-lockfile --verbose && rm -f .npmrc + env: + GH_REGISTRY_ACCESS_TOKEN: ${{ inputs.registry-token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 614a468..52169c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,105 +1,158 @@ -name: CI +name: 'CI' on: - push: - branches: - - main workflow_dispatch: - inputs: - workflow_to_run: - type: choice - description: Which workflow to run? - required: true - options: - - all - - hardhat-tests - - foundry-tests pull_request: - types: - - ready_for_review - - review_requested - pull_request_review: - types: [submitted] - -defaults: - run: - shell: bash + push: + branches: + - 'main' jobs: - run-linters: - if: github.ref == 'refs/heads/main' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested' + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 with: - node-version: 14 - - uses: actions/cache@v2 + node-version: 18 + cache: 'yarn' + + - name: Setup repo + uses: ./.github/actions/setup-repo with: - path: node_modules - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: yarn- + registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + - name: Install dependencies - run: | - npm config set //registry.npmjs.org/ - yarn install --frozen-lockfile + run: yarn install + - name: Run solhint - run: yarn lint:sol - - name: Run eslint - run: yarn lint:js:fix + run: yarn lint:check - hardhat-tests: - if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'hardhat-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested' + - name: 'Add lint summary' + run: | + echo "## Lint result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - uses: actions/setup-node@v3 with: - node-version: 14 - - uses: actions/cache@v2 + node-version: 18 + cache: 'yarn' + + - name: Setup repo + uses: ./.github/actions/setup-repo with: - path: node_modules - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: yarn- + registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + - name: Install dependencies - run: | - npm config set //registry.npmjs.org/ - yarn install --frozen-lockfile - - name: Compile + run: yarn install --frozen-lockfile + + - name: Compile hardhat run: yarn hardhat:compile + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Compile foundry + run: yarn foundry:compile --sizes + + - name: 'Cache the build so that it can be re-used by the other jobs' + uses: 'actions/cache/save@v3' + with: + key: 'build-${{ github.sha }}' + path: | + cache-forge + out + cache-hh + artifacts + typechain + node_modules + - name: 'Add build summary' + run: | + echo "## Build result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + + hardhat-tests: + needs: ['build', 'lint'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: 'Restore the cached build' + uses: 'actions/cache/restore@v3' + with: + fail-on-cache-miss: true + key: 'build-${{ github.sha }}' + path: | + cache-forge + out + cache-hh + artifacts + typechain + node_modules - run: export NODE_OPTIONS=--max_old_space_size=11264 - name: Run unit tests run: yarn hardhat:test env: ENABLE_GAS_REPORT: true CI: true - ETH_NODE_URI_FORKPOLYGON: ${{secrets.ETH_NODE_URI_FORKPOLYGON}} - ETH_NODE_URI_OPTIMISM: ${{secrets.ETH_NODE_URI_OPTIMISM}} - ETH_NODE_URI_AVALANCHE: ${{secrets.ETH_NODE_URI_AVALANCHE}} - ETH_NODE_URI_ARBITRUM: ${{secrets.ETH_NODE_URI_ARBITRUM}} - ETH_NODE_URI_MAINNET: ${{secrets.ETH_NODE_URI_MAINNET}} + ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }} + ETH_NODE_URI_FORK: ${{ secrets.ETH_NODE_URI_FORK }} + ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }} + + - name: 'Add test summary' + run: | + echo "## Hardhat Unit tests result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY foundry-tests: - if: github.ref == 'refs/heads/main' || github.event.inputs.workflow_to_run == 'all' || github.event.inputs.workflow_to_run == 'foundry-tests' || github.event.review.state == 'approved' || github.event.action == 'ready_for_review' || github.event.action == 'review_requested' + needs: ['build', 'lint'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - - uses: actions/setup-node@v2 with: - node-version: 14 - - uses: actions/cache@v2 - with: - path: node_modules - key: yarn-${{ hashFiles('yarn.lock') }} - restore-keys: yarn- - - run: yarn install --frozen-lockfile + submodules: 'recursive' - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly + + - name: 'Restore the cached build' + uses: 'actions/cache/restore@v3' + with: + fail-on-cache-miss: true + key: 'build-${{ github.sha }}' + path: | + cache-forge + out + cache-hh + artifacts + typechain + node_modules - name: Run Foundry tests run: yarn foundry:test env: ETH_NODE_URI_MAINNET: ${{ secrets.ETH_NODE_URI_MAINNET }} + ETH_NODE_URI_POLYGON: ${{ secrets.ETH_NODE_URI_POLYGON }} + ETH_NODE_URI_GOERLI: ${{ secrets.ETH_NODE_URI_GOERLI }} + ETH_NODE_URI_FANTOM: ${{ secrets.ETH_NODE_URI_FANTOM }} + FOUNDRY_FUZZ_RUNS: '5000' + + - name: 'Add test summary' + run: | + echo "## Foundry Unit tests result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..af66bba --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@angleprotocol:registry=https://npm.pkg.github.com diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..de01738 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +lib +artifacts +node_modules +cache-forge +cache-hh +export +out +typechain \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 11ad568..bc49639 100644 --- a/.prettierrc +++ b/.prettierrc @@ -12,8 +12,7 @@ "options": { "printWidth": 120, "singleQuote": false, - "bracketSpacing": true, - "explicitTypes": "always" + "bracketSpacing": true } } ] diff --git a/.solhint.json b/.solhint.json index 88814e5..4a90ce9 100644 --- a/.solhint.json +++ b/.solhint.json @@ -2,14 +2,27 @@ "extends": "solhint:recommended", "plugins": ["prettier"], "rules": { - "prettier/prettier": "warning", + "avoid-call-value": "warn", + "avoid-low-level-calls": "off", + "avoid-tx-origin": "warn", + "const-name-snakecase": "warn", + "contract-name-camelcase": "warn", + "imports-on-top": "warn", + "prettier/prettier": "off", "ordering": "off", + "max-states-count": "off", "mark-callable-contracts": "off", "no-empty-blocks": "off", + "no-global-import": "off", "not-rely-on-time": "off", "compiler-version": "off", - "private-vars-leading-underscore": "error", + "explicit-types": ["error", "explicit"], + "private-vars-leading-underscore": "warn", + "reentrancy": "warn", + "no-inline-assembly": "off", + "no-complex-fallback": "off", "reason-string": "off", - "func-visibility": ["error", { "ignoreConstructors": true }] + "func-visibility": ["warn", { "ignoreConstructors": true }], + "custom-errors": "off" } } diff --git a/.solhintignore b/.solhintignore index bc27d6b..174f4c1 100644 --- a/.solhintignore +++ b/.solhintignore @@ -1,2 +1,21 @@ contracts/interfaces/external/**/*.sol -contracts/mock/*.sol \ No newline at end of file +contracts/mock/*.sol + +# Doesn't need to lint dev files +lib +scripts +test +mock +deprecated + +# Doesn't need to lint build files +artifacts +node_modules +cache-forge +cache-hh +export +out +typechain + +# Doesn't need to lint utils files +external \ No newline at end of file diff --git a/contracts/BaseRouter.sol b/contracts/BaseRouter.sol index f9f623a..ee26a98 100644 --- a/contracts/BaseRouter.sol +++ b/contracts/BaseRouter.sol @@ -56,9 +56,11 @@ enum ActionType { unwrapNative, sweep, sweepNative, + // Deprecated uniswapV3, oneInch, claimRewards, + // Deprecated gaugeDeposit, borrower, swapper, @@ -73,16 +75,20 @@ enum ActionType { swapIn, swapOut, claimWeeklyInterest, + // Deprecated withdraw, // Deprecated mint, + // Deprecated deposit, // Deprecated openPerpetual, // Deprecated addToPerpetual, veANGLEDeposit, - claimRewardsWithPerps + // Deprecated + claimRewardsWithPerps, + deposit4626Referral } /// @notice Data needed to get permits @@ -136,8 +142,21 @@ abstract contract BaseRouter is Initializable { error TransferFailed(); error ZeroAddress(); + event ReferredDeposit( + address caller, + address indexed owner, + uint256 assets, + uint256 shares, + address indexed savings, + address indexed referrer + ); + /// @notice Deploys the router contract on a chain - function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer { + function initializeRouter( + address _core, + address _uniswapRouter, + address _oneInch + ) public initializer { if (_core == address(0)) revert ZeroAddress(); core = ICoreBorrow(_core); uniswapV3Router = IUniswapV3Router(_uniswapRouter); @@ -195,12 +214,6 @@ abstract contract BaseRouter is Initializable { } else if (actions[i] == ActionType.sweepNative) { uint256 routerBalance = address(this).balance; if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance); - } else if (actions[i] == ActionType.uniswapV3) { - (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode( - data[i], - (address, uint256, uint256, bytes) - ); - _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path); } else if (actions[i] == ActionType.oneInch) { (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode( data[i], @@ -210,12 +223,6 @@ abstract contract BaseRouter is Initializable { } else if (actions[i] == ActionType.claimRewards) { (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[])); _claimRewards(user, claimLiquidityGauges); - } else if (actions[i] == ActionType.gaugeDeposit) { - (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode( - data[i], - (address, uint256, address, bool) - ); - _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards); } else if (actions[i] == ActionType.borrower) { ( address collateral, @@ -254,6 +261,17 @@ abstract contract BaseRouter is Initializable { ); _changeAllowance(token, address(savingsRate), type(uint256).max); _deposit4626(savingsRate, amount, to, minSharesOut); + } else if (actions[i] == ActionType.deposit4626Referral) { + ( + IERC20 token, + IERC4626 savingsRate, + uint256 amount, + address to, + uint256 minSharesOut, + address referrer + ) = abi.decode(data[i], (IERC20, IERC4626, uint256, address, uint256, address)); + _changeAllowance(token, address(savingsRate), type(uint256).max); + _deposit4626Referral(savingsRate, amount, to, minSharesOut, referrer); } else if (actions[i] == ActionType.redeem4626) { (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode( data[i], @@ -272,6 +290,21 @@ abstract contract BaseRouter is Initializable { } } + /// @notice Wrapper built on top of the base `_deposit4626Referral` function to add a proxy enabling to track + /// addresses depositing from a certain referring address into an ERC4626 contract + function deposit4626Referral( + IERC20 token, + IERC4626 savings, + uint256 amount, + address to, + uint256 minSharesOut, + address referrer + ) external { + token.safeTransferFrom(msg.sender, address(this), amount); + _changeAllowance(token, address(savings), type(uint256).max); + _deposit4626Referral(savings, amount, to, minSharesOut, referrer); + } + /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing /// actions and then revoking this approval after these actions /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract @@ -370,27 +403,15 @@ abstract contract BaseRouter is Initializable { return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData); } - /// @notice Allows to deposit tokens into a gauge - /// @param user Address on behalf of which deposits should be made in the gauge - /// @param amount Amount to stake - /// @param gauge Liquidity gauge to stake in - /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards - /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true) - /// @dev The function will revert if the gauge has not already been approved by the contract - function _gaugeDeposit( - address user, - uint256 amount, - ILiquidityGauge gauge, - bool shouldClaimRewards - ) internal virtual { - gauge.deposit(amount, user, shouldClaimRewards); - } - /// @notice Sweeps tokens from the router contract /// @param tokenOut Token to sweep /// @param minAmountOut Minimum amount of tokens to recover /// @param to Address to which tokens should be sent - function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual { + function _sweep( + address tokenOut, + uint256 minAmountOut, + address to + ) internal virtual { uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this)); _slippageCheck(balanceToken, minAmountOut); if (balanceToken != 0) { @@ -418,26 +439,6 @@ abstract contract BaseRouter is Initializable { swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data); } - /// @notice Allows to swap between tokens via UniswapV3 (if there is a path) - /// @param inToken Token used as entrance of the swap - /// @param amount Amount of in token to swap - /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen - /// @param path Bytes representing the path to swap your input token to the accepted collateral - function _swapOnUniswapV3( - IERC20 inToken, - uint256 amount, - uint256 minAmountOut, - bytes memory path - ) internal returns (uint256 amountOut) { - // Approve transfer to the `uniswapV3Router` - // Since this router is supposed to be a trusted contract, we can leave the allowance to the token - address uniRouter = address(uniswapV3Router); - _changeAllowance(IERC20(inToken), uniRouter, type(uint256).max); - amountOut = IUniswapV3Router(uniRouter).exactInput( - ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut) - ); - } - /// @notice Swaps an inToken to another token via 1Inch Router /// @param payload Bytes needed for 1Inch router to process the swap /// @dev The `payload` given is expected to be obtained from 1Inch API @@ -488,6 +489,18 @@ abstract contract BaseRouter is Initializable { _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut); } + /// @notice Same as _deposit4626 but with the ability to specify a referring address + function _deposit4626Referral( + IERC4626 savingsRate, + uint256 amount, + address to, + uint256 minSharesOut, + address referrer + ) internal returns (uint256 sharesOut) { + sharesOut = _deposit4626(savingsRate, amount, to, minSharesOut); + emit ReferredDeposit(msg.sender, to, amount, sharesOut, address(savingsRate), referrer); + } + /// @notice Withdraws `amount` from an ERC4626 contract /// @param savingsRate ERC4626 to withdraw assets from /// @param amount Amount of assets to withdraw @@ -569,7 +582,11 @@ abstract contract BaseRouter is Initializable { /// @param token Address of the token to change allowance /// @param spender Address to change the allowance of /// @param amount Amount allowed - function _changeAllowance(IERC20 token, address spender, uint256 amount) internal { + function _changeAllowance( + IERC20 token, + address spender, + uint256 amount + ) internal { uint256 currentAllowance = token.allowance(address(this), spender); // In case `currentAllowance < type(uint256).max / 2` and we want to increase it: // Do nothing (to handle tokens that need reapprovals to 0 and save gas) diff --git a/contracts/implementations/base/AngleRouterBase.sol b/contracts/implementations/base/AngleRouterBase.sol new file mode 100644 index 0000000..4e2422b --- /dev/null +++ b/contracts/implementations/base/AngleRouterBase.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity ^0.8.17; + +import "../../BaseAngleRouterSidechain.sol"; + +/// @title AngleRouterBase +/// @author Angle Core Team +/// @notice Router contract built specifially for Angle use cases on Base +contract AngleRouterBase is BaseAngleRouterSidechain { + /// @inheritdoc BaseRouter + /// @dev There is no wCELO contract on CELO + function _getNativeWrapper() internal pure override returns (IWETH9) { + return IWETH9(0x4200000000000000000000000000000000000006); + } +} diff --git a/contracts/implementations/celo/AngleRouterCelo.sol b/contracts/implementations/celo/AngleRouterCelo.sol new file mode 100644 index 0000000..020a7aa --- /dev/null +++ b/contracts/implementations/celo/AngleRouterCelo.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity ^0.8.17; + +import "../../BaseAngleRouterSidechain.sol"; + +/// @title AngleRouterCelo +/// @author Angle Core Team +/// @notice Router contract built specifially for Angle use cases on Celo +contract AngleRouterCelo is BaseAngleRouterSidechain { + /// @inheritdoc BaseRouter + /// @dev There is no wCELO contract on CELO + function _getNativeWrapper() internal pure override returns (IWETH9) { + return IWETH9(0x0000000000000000000000000000000000000000); + } +} diff --git a/contracts/implementations/mainnet/AngleRouterMainnet.sol b/contracts/implementations/mainnet/AngleRouterMainnet.sol index c79e26c..b94a72a 100644 --- a/contracts/implementations/mainnet/AngleRouterMainnet.sol +++ b/contracts/implementations/mainnet/AngleRouterMainnet.sol @@ -44,49 +44,12 @@ contract AngleRouterMainnet is BaseRouter { /// @inheritdoc BaseRouter function _chainSpecificAction(ActionType action, bytes calldata data) internal override { - if (action == ActionType.claimRewardsWithPerps) { - ( - address user, - address[] memory claimLiquidityGauges, - uint256[] memory claimPerpetualIDs, - bool addressProcessed, - address[] memory stablecoins, - address[] memory collateralsOrPerpetualManagers - ) = abi.decode(data, (address, address[], uint256[], bool, address[], address[])); - _claimRewardsWithPerps( - user, - claimLiquidityGauges, - claimPerpetualIDs, - addressProcessed, - stablecoins, - collateralsOrPerpetualManagers - ); - } else if (action == ActionType.claimWeeklyInterest) { + if (action == ActionType.claimWeeklyInterest) { (address user, address feeDistributor, bool letInContract) = abi.decode(data, (address, address, bool)); _claimWeeklyInterest(user, IFeeDistributorFront(feeDistributor), letInContract); } else if (action == ActionType.veANGLEDeposit) { (address user, uint256 amount) = abi.decode(data, (address, uint256)); _depositOnLocker(user, amount); - } else if (action == ActionType.deposit) { - ( - address user, - uint256 amount, - bool addressProcessed, - address stablecoinOrStableMaster, - address collateral, - address poolManager - ) = abi.decode(data, (address, uint256, bool, address, address, address)); - _deposit(user, amount, addressProcessed, stablecoinOrStableMaster, collateral, IPoolManager(poolManager)); - } else if (action == ActionType.withdraw) { - ( - uint256 amount, - bool addressProcessed, - address stablecoinOrStableMaster, - address collateralOrPoolManager, - address sanToken - ) = abi.decode(data, (uint256, bool, address, address, address)); - if (amount == type(uint256).max) amount = IERC20(sanToken).balanceOf(address(this)); - _withdraw(amount, addressProcessed, stablecoinOrStableMaster, collateralOrPoolManager); } } @@ -95,48 +58,6 @@ contract AngleRouterMainnet is BaseRouter { return IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); } - /// @notice Claims rewards for multiple gauges and perpetuals at once - /// @param gaugeUser Address for which to fetch the rewards from the gauges - /// @param liquidityGauges Gauges to claim on - /// @param perpetualIDs Perpetual IDs to claim rewards for - /// @param addressProcessed Whether `PerpetualManager` list is already accessible in `collateralsOrPerpetualManagers` or if - /// it should be retrieved from `stablecoins` and `collateralsOrPerpetualManagers` - /// @param stablecoins Stablecoin contracts linked to the perpetualsIDs. Array of zero addresses if `addressProcessed` is true - /// @param collateralsOrPerpetualManagers Collateral contracts linked to the perpetualsIDs or `perpetualManager` contracts if - /// `addressProcessed` is true - function _claimRewardsWithPerps( - address gaugeUser, - address[] memory liquidityGauges, - uint256[] memory perpetualIDs, - bool addressProcessed, - address[] memory stablecoins, - address[] memory collateralsOrPerpetualManagers - ) internal { - uint256 perpetualIDsLength = perpetualIDs.length; - if ( - perpetualIDsLength != 0 && - (stablecoins.length != perpetualIDsLength || collateralsOrPerpetualManagers.length != perpetualIDsLength) - ) revert IncompatibleLengths(); - - uint256 liquidityGaugesLength = liquidityGauges.length; - for (uint256 i; i < liquidityGaugesLength; ++i) { - ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser); - } - - for (uint256 i; i < perpetualIDsLength; ++i) { - IPerpetualManagerFrontWithClaim perpManager; - if (addressProcessed) perpManager = IPerpetualManagerFrontWithClaim(collateralsOrPerpetualManagers[i]); - else { - (, Pairs memory pairs) = _getInternalContracts( - IERC20(stablecoins[i]), - IERC20(collateralsOrPerpetualManagers[i]) - ); - perpManager = pairs.perpetualManager; - } - perpManager.getReward(perpetualIDs[i]); - } - } - /// @notice Deposits ANGLE on an existing locker /// @param user Address to deposit for /// @param amount Amount to deposit @@ -149,7 +70,11 @@ contract AngleRouterMainnet is BaseRouter { /// @param _feeDistributor Address of the fee distributor to claim to /// @dev If `letInContract` (and hence if funds are transferred to the router), you should approve the `angleRouter` to /// transfer the token claimed from the `feeDistributor` - function _claimWeeklyInterest(address user, IFeeDistributorFront _feeDistributor, bool letInContract) internal { + function _claimWeeklyInterest( + address user, + IFeeDistributorFront _feeDistributor, + bool letInContract + ) internal { uint256 amount = _feeDistributor.claim(user); if (letInContract) { // Fetching info from the `FeeDistributor` to process correctly the withdrawal @@ -158,81 +83,8 @@ contract AngleRouterMainnet is BaseRouter { } } - /// @notice Deposits collateral in the Core Module of the protocol - /// @param user Address where to send the resulting sanTokens, if this address is the router address then it means - /// that the intention is to stake the sanTokens obtained in a subsequent `gaugeDeposit` action - /// @param amount Amount of collateral to deposit - /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones - /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false) - /// or directly the `StableMaster` contract if `addressProcessed` - /// @param collateral Token to deposit: it can be null if `addressProcessed` is true but in the corresponding - /// action, the `mixer` needs to get a correct address to compute the amount of tokens to use for the deposit - /// @param poolManager PoolManager associated to the `collateral` (null if `addressProcessed` is not true) - function _deposit( - address user, - uint256 amount, - bool addressProcessed, - address stablecoinOrStableMaster, - address collateral, - IPoolManager poolManager - ) internal { - IStableMasterFront stableMaster; - if (addressProcessed) { - stableMaster = IStableMasterFront(stablecoinOrStableMaster); - } else { - Pairs memory pairs; - (stableMaster, pairs) = _getInternalContracts(IERC20(stablecoinOrStableMaster), IERC20(collateral)); - poolManager = pairs.poolManager; - } - stableMaster.deposit(amount, user, poolManager); - } - - /// @notice Withdraws sanTokens from the protocol - /// @param amount Amount of sanTokens to withdraw - /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones - /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false) - /// or directly the `StableMaster` contract if `addressProcessed` - /// @param collateralOrPoolManager Collateral to withdraw (if `addressProcessed` is false) or directly - /// the `PoolManager` contract if `addressProcessed` - function _withdraw( - uint256 amount, - bool addressProcessed, - address stablecoinOrStableMaster, - address collateralOrPoolManager - ) internal { - IStableMasterFront stableMaster; - IPoolManager poolManager; - if (addressProcessed) { - stableMaster = IStableMasterFront(stablecoinOrStableMaster); - poolManager = IPoolManager(collateralOrPoolManager); - } else { - Pairs memory pairs; - (stableMaster, pairs) = _getInternalContracts( - IERC20(stablecoinOrStableMaster), - IERC20(collateralOrPoolManager) - ); - poolManager = pairs.poolManager; - } - stableMaster.withdraw(amount, address(this), address(this), poolManager); - } - // ========================= INTERNAL UTILITY FUNCTIONS ======================== - /// @notice Gets Angle contracts associated to a pair (stablecoin, collateral) - /// @param stablecoin Token associated to a `StableMaster` - /// @param collateral Collateral to mint/deposit/open perpetual or add collateral from - /// @dev This function is used to check that the parameters passed by people calling some of the main - /// router functions are correct - function _getInternalContracts( - IERC20 stablecoin, - IERC20 collateral - ) internal view returns (IStableMasterFront stableMaster, Pairs memory pairs) { - stableMaster = mapStableMasters[stablecoin]; - pairs = mapPoolManagers[stableMaster][collateral]; - if (address(stableMaster) == address(0) || address(pairs.poolManager) == address(0)) revert ZeroAddress(); - return (stableMaster, pairs); - } - /// @notice Returns the veANGLE address function _getVeANGLE() internal view virtual returns (IVeANGLE) { return IVeANGLE(0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5); diff --git a/deploy/networks/base.json b/deploy/networks/base.json new file mode 100644 index 0000000..6bde4bf --- /dev/null +++ b/deploy/networks/base.json @@ -0,0 +1,4 @@ +{ + "uniswapV3Router": "0x2626664c2603336E57B271c5C0b26F421741e481", + "oneInchRouter": "0x1111111254eeb25477b68fb85ed929f73a960582" +} diff --git a/deploy/networks/celo.json b/deploy/networks/celo.json new file mode 100644 index 0000000..ada14d2 --- /dev/null +++ b/deploy/networks/celo.json @@ -0,0 +1,4 @@ +{ + "oneInchRouter": "0x0000000000000000000000000000000000000000", + "uniswapV3Router": "0x0000000000000000000000000000000000000000" +} diff --git a/deploy/networks/index.ts b/deploy/networks/index.ts deleted file mode 100644 index 8d43cf7..0000000 --- a/deploy/networks/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ChainId, CONSTANTS } from '@angleprotocol/sdk'; -import { network } from 'hardhat'; - -// In case it is a mainnet fork, take the appropriate params -export default CONSTANTS((network.live && network.config.chainId === 1337 ? 1 : network.config.chainId) as ChainId); diff --git a/deploy/routerSidechain.ts b/deploy/routerSidechain.ts index d12bcf8..b913b1f 100644 --- a/deploy/routerSidechain.ts +++ b/deploy/routerSidechain.ts @@ -16,10 +16,10 @@ const func: DeployFunction = async ({ ethers, deployments, network }) => { let chainName: string; if (!network.live) { - chainId = ChainId.POLYGON; - chainName = 'Polygon'; + chainId = ChainId.BASE; + chainName = 'Base'; } else { - chainId = ChainId.GNOSIS; + chainId = ChainId.BASE; chainName = network.name.charAt(0).toUpperCase() + network.name.substring(1); } diff --git a/deployments/base/.chainId b/deployments/base/.chainId new file mode 100644 index 0000000..2a0c263 --- /dev/null +++ b/deployments/base/.chainId @@ -0,0 +1 @@ +8453 \ No newline at end of file diff --git a/deployments/base/AngleRouterBaseV2.json b/deployments/base/AngleRouterBaseV2.json new file mode 100644 index 0000000..ccf3f38 --- /dev/null +++ b/deployments/base/AngleRouterBaseV2.json @@ -0,0 +1,247 @@ +{ + "address": "0x423Cf4cD872F912D278DF2F54Ae58Aa8073cb38c", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x2daf4ca5156d988d8c5b85b5a90057ea6808035fa10939150a4e075d8a2e6ed0", + "receipt": { + "to": null, + "from": "0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185", + "contractAddress": "0x423Cf4cD872F912D278DF2F54Ae58Aa8073cb38c", + "transactionIndex": 36, + "gasUsed": "759122", + "logsBloom": "0x00000000100000000100000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000010000000000000000000000000000000000000800000000000000000200000000000100000000000000001000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x74b0c37c813fb5bd91cac9cad0dc93660ac397b51725aab0080eb7c24ea2ccf8", + "transactionHash": "0x2daf4ca5156d988d8c5b85b5a90057ea6808035fa10939150a4e075d8a2e6ed0", + "logs": [ + { + "transactionIndex": 36, + "blockNumber": 13370522, + "transactionHash": "0x2daf4ca5156d988d8c5b85b5a90057ea6808035fa10939150a4e075d8a2e6ed0", + "address": "0x423Cf4cD872F912D278DF2F54Ae58Aa8073cb38c", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000064c4671e682ad4b58cede027a0a3ec21c6fe6182" + ], + "data": "0x", + "logIndex": 159, + "blockHash": "0x74b0c37c813fb5bd91cac9cad0dc93660ac397b51725aab0080eb7c24ea2ccf8" + }, + { + "transactionIndex": 36, + "blockNumber": 13370522, + "transactionHash": "0x2daf4ca5156d988d8c5b85b5a90057ea6808035fa10939150a4e075d8a2e6ed0", + "address": "0x423Cf4cD872F912D278DF2F54Ae58Aa8073cb38c", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 160, + "blockHash": "0x74b0c37c813fb5bd91cac9cad0dc93660ac397b51725aab0080eb7c24ea2ccf8" + }, + { + "transactionIndex": 36, + "blockNumber": 13370522, + "transactionHash": "0x2daf4ca5156d988d8c5b85b5a90057ea6808035fa10939150a4e075d8a2e6ed0", + "address": "0x423Cf4cD872F912D278DF2F54Ae58Aa8073cb38c", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d941ef0d3bba4ad67dbfbcee5262f4cee53a32b", + "logIndex": 161, + "blockHash": "0x74b0c37c813fb5bd91cac9cad0dc93660ac397b51725aab0080eb7c24ea2ccf8" + } + ], + "blockNumber": 13370522, + "cumulativeGasUsed": "6409941", + "status": 1, + "byzantium": true + }, + "args": [ + "0x64c4671E682aD4b58cEde027A0A3EC21C6fE6182", + "0x1D941EF0D3Bba4ad67DBfBCeE5262F4CEE53A32b", + "0x42860d4b0000000000000000000000004b1e2c2762667331bc91648052f646d1b0d359840000000000000000000000002626664c2603336e57b271c5c0b26f421741e4810000000000000000000000001111111254eeb25477b68fb85ed929f73a960582" + ], + "numDeployments": 1, + "solcInputHash": "382e5f7965175dcf029b988f27abf9db", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin `TransparentUpgradeableProxy` To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/external/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"contracts/external/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin\\n * `TransparentUpgradeableProxy`\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xdbb2775fbc740793c0b3d5927cca8b9976cc4f9caef50178d1be0aa7afca14e6\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x6080604052604051620010bb380380620010bb8339810160408190526200002691620004d8565b828162000036828260006200009a565b5062000066905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005b8565b6000805160206200107483398151915214620000865762000086620005da565b6200009182620000d7565b50505062000643565b620000a58362000132565b600082511180620000b35750805b15620000d257620000d083836200017460201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f62000102620001a5565b604080516001600160a01b03928316815291841660208301520160405180910390a16200012f81620001de565b50565b6200013d8162000293565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200019c8383604051806060016040528060278152602001620010946027913962000347565b90505b92915050565b6000620001cf6000805160206200107483398151915260001b6200042f60201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002495760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002726000805160206200107483398151915260001b6200042f60201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002a9816200043260201b620002b81760201c565b6200030d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840162000240565b80620002727f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b6200042f60201b6200022e1760201c565b60606001600160a01b0384163b620003b15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840162000240565b600080856001600160a01b031685604051620003ce9190620005f0565b600060405180830381855af49150503d80600081146200040b576040519150601f19603f3d011682016040523d82523d6000602084013e62000410565b606091505b5090925090506200042382828662000441565b925050505b9392505050565b90565b6001600160a01b03163b151590565b606083156200045257508162000428565b825115620004635782518084602001fd5b8160405162461bcd60e51b81526004016200024091906200060e565b80516001600160a01b03811681146200049757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004cf578181015183820152602001620004b5565b50506000910152565b600080600060608486031215620004ee57600080fd5b620004f9846200047f565b925062000509602085016200047f565b60408501519092506001600160401b03808211156200052757600080fd5b818601915086601f8301126200053c57600080fd5b8151818111156200055157620005516200049c565b604051601f8201601f19908116603f011681019083821181831017156200057c576200057c6200049c565b816040528281528960208487010111156200059657600080fd5b620005a9836020830160208801620004b2565b80955050505050509250925092565b818103818111156200019f57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b6000825162000604818460208701620004b2565b9190910192915050565b60208152600082518060208401526200062f816040850160208701620004b2565b601f01601f19169190910160400192915050565b610a2180620006536000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109c5602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105739190610957565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610973565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b50506000910152565b60008251610969818460208701610933565b9190910192915050565b6020815260008251806020840152610992816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051812c356928ef88014789eaeb04ce9454e2ec8e03025a1ceedcece2f91bca8964736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109c5602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105739190610957565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610973565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b50506000910152565b60008251610969818460208701610933565b9190910192915050565b6020815260008251806020840152610992816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051812c356928ef88014789eaeb04ce9454e2ec8e03025a1ceedcece2f91bca8964736f6c63430008110033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin `TransparentUpgradeableProxy` To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/base/AngleRouterBaseV2_1_Implementation.json b/deployments/base/AngleRouterBaseV2_1_Implementation.json new file mode 100644 index 0000000..94ee82a --- /dev/null +++ b/deployments/base/AngleRouterBaseV2_1_Implementation.json @@ -0,0 +1,556 @@ +{ + "address": "0x64c4671E682aD4b58cEde027A0A3EC21C6fE6182", + "abi": [ + { + "inputs": [], + "name": "IncompatibleLengths", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidReturnMessage", + "type": "error" + }, + { + "inputs": [], + "name": "NotApprovedOrOwner", + "type": "error" + }, + { + "inputs": [], + "name": "NotGovernor", + "type": "error" + }, + { + "inputs": [], + "name": "NotGovernorOrGuardian", + "type": "error" + }, + { + "inputs": [], + "name": "TooSmallAmountOut", + "type": "error" + }, + { + "inputs": [], + "name": "TransferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "spenders", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "changeAllowance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "gaugeUser", + "type": "address" + }, + { + "internalType": "address[]", + "name": "liquidityGauges", + "type": "address[]" + } + ], + "name": "claimRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract ICoreBorrow", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_core", + "type": "address" + }, + { + "internalType": "address", + "name": "_uniswapRouter", + "type": "address" + }, + { + "internalType": "address", + "name": "_oneInch", + "type": "address" + } + ], + "name": "initializeRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitType[]", + "name": "paramsPermit", + "type": "tuple[]" + }, + { + "internalType": "enum ActionType[]", + "name": "actions", + "type": "uint8[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "mixer", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vaultManager", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitVaultManagerType[]", + "name": "paramsPermitVaultManager", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitType[]", + "name": "paramsPermit", + "type": "tuple[]" + }, + { + "internalType": "enum ActionType[]", + "name": "actions", + "type": "uint8[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "mixerVaultManagerPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "oneInch", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICoreBorrow", + "name": "_core", + "type": "address" + } + ], + "name": "setCore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "uint8", + "name": "who", + "type": "uint8" + } + ], + "name": "setRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "uniswapV3Router", + "outputs": [ + { + "internalType": "contract IUniswapV3Router", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xa0b241a15e253c25c903c15bc9bbc0c5312ee0e28f08af4a87d74e20df2d5737", + "receipt": { + "to": null, + "from": "0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185", + "contractAddress": "0x64c4671E682aD4b58cEde027A0A3EC21C6fE6182", + "transactionIndex": 48, + "gasUsed": "3803657", + "logsBloom": "0x00000000000000000000800000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xd34dfc437bf13c99132a47037b01ea9445befa031c1f099d79e34284357ec763", + "transactionHash": "0xa0b241a15e253c25c903c15bc9bbc0c5312ee0e28f08af4a87d74e20df2d5737", + "logs": [ + { + "transactionIndex": 48, + "blockNumber": 13370519, + "transactionHash": "0xa0b241a15e253c25c903c15bc9bbc0c5312ee0e28f08af4a87d74e20df2d5737", + "address": "0x64c4671E682aD4b58cEde027A0A3EC21C6fE6182", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 116, + "blockHash": "0xd34dfc437bf13c99132a47037b01ea9445befa031c1f099d79e34284357ec763" + } + ], + "blockNumber": 13370519, + "cumulativeGasUsed": "8122017", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "70c4b5d324ac01a99c0faeb5728c1fc2", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"IncompatibleLengths\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidReturnMessage\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotApprovedOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotGovernor\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotGovernorOrGuardian\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TooSmallAmountOut\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"spenders\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"changeAllowance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gaugeUser\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"liquidityGauges\",\"type\":\"address[]\"}],\"name\":\"claimRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"core\",\"outputs\":[{\"internalType\":\"contract ICoreBorrow\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_core\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_uniswapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_oneInch\",\"type\":\"address\"}],\"name\":\"initializeRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitType[]\",\"name\":\"paramsPermit\",\"type\":\"tuple[]\"},{\"internalType\":\"enum ActionType[]\",\"name\":\"actions\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"mixer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"vaultManager\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitVaultManagerType[]\",\"name\":\"paramsPermitVaultManager\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitType[]\",\"name\":\"paramsPermit\",\"type\":\"tuple[]\"},{\"internalType\":\"enum ActionType[]\",\"name\":\"actions\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"mixerVaultManagerPermit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oneInch\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICoreBorrow\",\"name\":\"_core\",\"type\":\"address\"}],\"name\":\"setCore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"who\",\"type\":\"uint8\"}],\"name\":\"setRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"uniswapV3Router\",\"outputs\":[{\"internalType\":\"contract IUniswapV3Router\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"Angle Core Team\",\"kind\":\"dev\",\"methods\":{\"changeAllowance(address[],address[],uint256[])\":{\"params\":{\"amounts\":\"Amounts to allow\",\"spenders\":\"Addresses to allow transfer\",\"tokens\":\"Addresses of the tokens to allow\"}},\"claimRewards(address,address[])\":{\"details\":\"If the caller wants to send the rewards to another account it first needs to call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\",\"params\":{\"gaugeUser\":\"Address for which to fetch the rewards from the gauges\",\"liquidityGauges\":\"Gauges to claim on\"}},\"mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"details\":\"With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol does not verify the payload given and cannot check that the swap performed by users actually gives the desired out token: in this case funds may be made accessible to anyone on this contract if the concerned users do not perform a sweep action on these tokens\",\"params\":{\"actions\":\"List of actions to be performed by the router (in order of execution)\",\"data\":\"Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters for a given action are stored\",\"paramsPermit\":\"Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\"}},\"mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"details\":\"In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures to revoke approvalsThe router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this is just an option\",\"params\":{\"paramsPermitVaultManager\":\"Parameters to sign permit to give allowance to the router for a `VaultManager` contract\"}}},\"title\":\"AngleRouterBase\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"changeAllowance(address[],address[],uint256[])\":{\"notice\":\"Changes allowances for different tokens\"},\"claimRewards(address,address[])\":{\"notice\":\"Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple gauges at once\"},\"core()\":{\"notice\":\"Core address handling access control\"},\"initializeRouter(address,address,address)\":{\"notice\":\"Deploys the router contract on a chain\"},\"mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"notice\":\"Allows composable calls to different functions within the protocol\"},\"mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"notice\":\"Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing actions and then revoking this approval after these actions\"},\"oneInch()\":{\"notice\":\"Address of 1Inch router used for swaps\"},\"setCore(address)\":{\"notice\":\"Sets a new `core` contract\"},\"setRouter(address,uint8)\":{\"notice\":\"Sets a new router variable\"},\"uniswapV3Router()\":{\"notice\":\"Address of the router used for swaps\"}},\"notice\":\"Router contract built specifially for Angle use cases on Base\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/implementations/base/AngleRouterBase.sol\":\"AngleRouterBase\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../token/ERC20/IERC20.sol\\\";\\n\",\"keccak256\":\"0x6ebf1944ab804b8660eb6fc52f9fe84588cee01c2566a69023e59497e7d27f45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../token/ERC20/IERC20.sol\\\";\\nimport \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n *\\n * _Available since v4.7._\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x9750c6fec736eb3320e85924f36a3060fa4a4ab1758d06d9585e175d164eefdb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\\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 function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-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 function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) 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(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) 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 function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\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 if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"contracts/BaseAngleRouterSidechain.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"./interfaces/IAgTokenMultiChain.sol\\\";\\nimport \\\"./BaseRouter.sol\\\";\\n\\n/// @title BaseAngleRouterSidechain\\n/// @author Angle Core Team\\n/// @notice Extension of the `BaseRouter` contract for sidechains\\nabstract contract BaseAngleRouterSidechain is BaseRouter {\\n // =========================== ROUTER FUNCTIONALITIES ==========================\\n\\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\\n /// gauges at once\\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\\n /// @param liquidityGauges Gauges to claim on\\n /// @dev If the caller wants to send the rewards to another account it first needs to\\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\\n _claimRewards(gaugeUser, liquidityGauges);\\n }\\n\\n /// @inheritdoc BaseRouter\\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\\n if (action == ActionType.swapIn) {\\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\\n .decode(data, (address, address, uint256, uint256, address));\\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\\n } else if (action == ActionType.swapOut) {\\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\\n .decode(data, (address, address, uint256, uint256, address));\\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\\n }\\n }\\n\\n /// @notice Wraps a bridge token to its corresponding canonical version\\n function _swapIn(\\n address canonicalToken,\\n address bridgeToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n address to\\n ) internal returns (uint256) {\\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\\n _slippageCheck(amount, minAmountOut);\\n return amount;\\n }\\n\\n /// @notice Unwraps a canonical token for one of its bridge version\\n function _swapOut(\\n address canonicalToken,\\n address bridgeToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n address to\\n ) internal returns (uint256) {\\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\\n _slippageCheck(amount, minAmountOut);\\n return amount;\\n }\\n}\\n\",\"keccak256\":\"0xe3503193ad3da691e6308881cf8e87dbe1f1714b5474c8b66aadf8764c2c5116\",\"license\":\"GPL-3.0\"},\"contracts/BaseRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\n/*\\n * \\u2588 \\n ***** \\u2593\\u2593\\u2593 \\n * \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n * ///. \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n ***** //////// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n * ///////////// \\u2593\\u2593\\u2593 \\n \\u2593\\u2593 ////////////////// \\u2588 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 /////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 //////////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 /////////\\u2593\\u2593\\u2593///////\\u2593\\u2593\\u2593///////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 ,////////////////////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 ////////////////////////////////////////// \\u2593\\u2593 \\n \\u2593\\u2593 //////////////////////\\u2593\\u2593\\u2593\\u2593///////////////////// \\n ,//////////////////////////////////////////////////// \\n .////////////////////////////////////////////////////////// \\n .//////////////////////////\\u2588\\u2588.,//////////////////////////\\u2588 \\n .//////////////////////\\u2588\\u2588\\u2588\\u2588..,./////////////////////\\u2588\\u2588 \\n ...////////////////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588.....,.////////////////\\u2588\\u2588\\u2588 \\n ,.,////////////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ........,///////////\\u2588\\u2588\\u2588\\u2588 \\n .,.,//////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ,.......///////\\u2588\\u2588\\u2588\\u2588 \\n ,..//\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ........./\\u2588\\u2588\\u2588\\u2588 \\n ..,\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 .....,\\u2588\\u2588\\u2588 \\n .\\u2588\\u2588 ,.,\\u2588 \\n \\n \\n \\n \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n*/\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\nimport \\\"./interfaces/external/uniswap/IUniswapRouter.sol\\\";\\nimport \\\"./interfaces/external/IWETH9.sol\\\";\\nimport \\\"./interfaces/ICoreBorrow.sol\\\";\\nimport \\\"./interfaces/ILiquidityGauge.sol\\\";\\nimport \\\"./interfaces/ISwapper.sol\\\";\\nimport \\\"./interfaces/IVaultManager.sol\\\";\\n\\n// ============================== STRUCTS AND ENUM =============================\\n\\n/// @notice Action types\\nenum ActionType {\\n transfer,\\n wrapNative,\\n unwrapNative,\\n sweep,\\n sweepNative,\\n uniswapV3,\\n oneInch,\\n claimRewards,\\n gaugeDeposit,\\n borrower,\\n swapper,\\n mint4626,\\n deposit4626,\\n redeem4626,\\n withdraw4626,\\n // Deprecated\\n prepareRedeemSavingsRate,\\n // Deprecated\\n claimRedeemSavingsRate,\\n swapIn,\\n swapOut,\\n claimWeeklyInterest,\\n withdraw,\\n // Deprecated\\n mint,\\n deposit,\\n // Deprecated\\n openPerpetual,\\n // Deprecated\\n addToPerpetual,\\n veANGLEDeposit,\\n claimRewardsWithPerps\\n}\\n\\n/// @notice Data needed to get permits\\nstruct PermitType {\\n address token;\\n address owner;\\n uint256 value;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\n/// @notice Data to grant permit to the router for a vault\\nstruct PermitVaultManagerType {\\n address vaultManager;\\n address owner;\\n bool approved;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\n/// @title BaseRouter\\n/// @author Angle Core Team\\n/// @notice Base contract that Angle router contracts on different chains should override\\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\\nabstract contract BaseRouter is Initializable {\\n using SafeERC20 for IERC20;\\n\\n // ================================= REFERENCES ================================\\n\\n /// @notice Core address handling access control\\n ICoreBorrow public core;\\n /// @notice Address of the router used for swaps\\n IUniswapV3Router public uniswapV3Router;\\n /// @notice Address of 1Inch router used for swaps\\n address public oneInch;\\n\\n uint256[47] private __gap;\\n\\n // ============================== EVENTS / ERRORS ==============================\\n\\n error IncompatibleLengths();\\n error InvalidReturnMessage();\\n error NotApprovedOrOwner();\\n error NotGovernor();\\n error NotGovernorOrGuardian();\\n error TooSmallAmountOut();\\n error TransferFailed();\\n error ZeroAddress();\\n\\n /// @notice Deploys the router contract on a chain\\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\\n if (_core == address(0)) revert ZeroAddress();\\n core = ICoreBorrow(_core);\\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\\n oneInch = _oneInch;\\n }\\n\\n constructor() initializer {}\\n\\n // =========================== ROUTER FUNCTIONALITIES ==========================\\n\\n /// @notice Allows composable calls to different functions within the protocol\\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\\n /// @param actions List of actions to be performed by the router (in order of execution)\\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\\n /// for a given action are stored\\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\\n /// do not perform a sweep action on these tokens\\n function mixer(\\n PermitType[] memory paramsPermit,\\n ActionType[] calldata actions,\\n bytes[] calldata data\\n ) public payable virtual {\\n // If all tokens have already been approved, there's no need for this step\\n uint256 permitsLength = paramsPermit.length;\\n for (uint256 i; i < permitsLength; ++i) {\\n IERC20Permit(paramsPermit[i].token).permit(\\n paramsPermit[i].owner,\\n address(this),\\n paramsPermit[i].value,\\n paramsPermit[i].deadline,\\n paramsPermit[i].v,\\n paramsPermit[i].r,\\n paramsPermit[i].s\\n );\\n }\\n // Performing actions one after the others\\n uint256 actionsLength = actions.length;\\n for (uint256 i; i < actionsLength; ++i) {\\n if (actions[i] == ActionType.transfer) {\\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\\n } else if (actions[i] == ActionType.wrapNative) {\\n _wrapNative();\\n } else if (actions[i] == ActionType.unwrapNative) {\\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\\n _unwrapNative(minAmountOut, to);\\n } else if (actions[i] == ActionType.sweep) {\\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\\n _sweep(tokenOut, minAmountOut, to);\\n } else if (actions[i] == ActionType.sweepNative) {\\n uint256 routerBalance = address(this).balance;\\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\\n } else if (actions[i] == ActionType.uniswapV3) {\\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\\n data[i],\\n (address, uint256, uint256, bytes)\\n );\\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\\n } else if (actions[i] == ActionType.oneInch) {\\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\\n data[i],\\n (address, uint256, bytes)\\n );\\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\\n } else if (actions[i] == ActionType.claimRewards) {\\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\\n _claimRewards(user, claimLiquidityGauges);\\n } else if (actions[i] == ActionType.gaugeDeposit) {\\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\\n data[i],\\n (address, uint256, address, bool)\\n );\\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\\n } else if (actions[i] == ActionType.borrower) {\\n (\\n address collateral,\\n address vaultManager,\\n address to,\\n address who,\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n bytes memory repayData\\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\\n } else if (actions[i] == ActionType.swapper) {\\n (\\n ISwapper swapperContract,\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory payload\\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\\n } else if (actions[i] == ActionType.mint4626) {\\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\\n data[i],\\n (IERC20, IERC4626, uint256, address, uint256)\\n );\\n _changeAllowance(token, address(savingsRate), type(uint256).max);\\n _mint4626(savingsRate, shares, to, maxAmountIn);\\n } else if (actions[i] == ActionType.deposit4626) {\\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\\n data[i],\\n (IERC20, IERC4626, uint256, address, uint256)\\n );\\n _changeAllowance(token, address(savingsRate), type(uint256).max);\\n _deposit4626(savingsRate, amount, to, minSharesOut);\\n } else if (actions[i] == ActionType.redeem4626) {\\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\\n data[i],\\n (IERC4626, uint256, address, uint256)\\n );\\n _redeem4626(savingsRate, shares, to, minAmountOut);\\n } else if (actions[i] == ActionType.withdraw4626) {\\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\\n data[i],\\n (IERC4626, uint256, address, uint256)\\n );\\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\\n } else {\\n _chainSpecificAction(actions[i], data[i]);\\n }\\n }\\n }\\n\\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\\n /// actions and then revoking this approval after these actions\\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\\n /// to revoke approvals\\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\\n /// is just an option\\n function mixerVaultManagerPermit(\\n PermitVaultManagerType[] memory paramsPermitVaultManager,\\n PermitType[] memory paramsPermit,\\n ActionType[] calldata actions,\\n bytes[] calldata data\\n ) external payable virtual {\\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\\n for (uint256 i; i < permitVaultManagerLength; ++i) {\\n if (paramsPermitVaultManager[i].approved) {\\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\\n paramsPermitVaultManager[i].owner,\\n address(this),\\n true,\\n paramsPermitVaultManager[i].deadline,\\n paramsPermitVaultManager[i].v,\\n paramsPermitVaultManager[i].r,\\n paramsPermitVaultManager[i].s\\n );\\n } else break;\\n }\\n mixer(paramsPermit, actions, data);\\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\\n // too deep\\n for (uint256 i; i < permitVaultManagerLength; ++i) {\\n if (!paramsPermitVaultManager[i].approved) {\\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\\n paramsPermitVaultManager[i].owner,\\n address(this),\\n false,\\n paramsPermitVaultManager[i].deadline,\\n paramsPermitVaultManager[i].v,\\n paramsPermitVaultManager[i].r,\\n paramsPermitVaultManager[i].s\\n );\\n }\\n }\\n }\\n\\n receive() external payable {}\\n\\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\\n\\n /// @notice Wraps the native token of a chain to its wrapped version\\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\\n /// @dev The amount to wrap is to be specified in the `msg.value`\\n function _wrapNative() internal virtual returns (uint256) {\\n _getNativeWrapper().deposit{ value: msg.value }();\\n return msg.value;\\n }\\n\\n /// @notice Unwraps the wrapped version of a token to the native chain token\\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\\n amount = _getNativeWrapper().balanceOf(address(this));\\n _slippageCheck(amount, minAmountOut);\\n if (amount != 0) {\\n _getNativeWrapper().withdraw(amount);\\n _safeTransferNative(to, amount);\\n }\\n return amount;\\n }\\n\\n /// @notice Internal version of the `claimRewards` function\\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\\n uint256 gaugesLength = liquidityGauges.length;\\n for (uint256 i; i < gaugesLength; ++i) {\\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\\n }\\n }\\n\\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\\n /// @param vaultManager Address of the vault to perform actions on\\n /// @param actionsBorrow Actions type to perform on the vaultManager\\n /// @param dataBorrow Data needed for each actions\\n /// @param to Address to send the funds to\\n /// @param who Swapper address to handle repayments\\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\\n function _angleBorrower(\\n address vaultManager,\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n address to,\\n address who,\\n bytes memory repayData\\n ) internal virtual returns (PaymentData memory paymentData) {\\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\\n }\\n\\n /// @notice Allows to deposit tokens into a gauge\\n /// @param user Address on behalf of which deposits should be made in the gauge\\n /// @param amount Amount to stake\\n /// @param gauge Liquidity gauge to stake in\\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\\n /// @dev The function will revert if the gauge has not already been approved by the contract\\n function _gaugeDeposit(\\n address user,\\n uint256 amount,\\n ILiquidityGauge gauge,\\n bool shouldClaimRewards\\n ) internal virtual {\\n gauge.deposit(amount, user, shouldClaimRewards);\\n }\\n\\n /// @notice Sweeps tokens from the router contract\\n /// @param tokenOut Token to sweep\\n /// @param minAmountOut Minimum amount of tokens to recover\\n /// @param to Address to which tokens should be sent\\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\\n _slippageCheck(balanceToken, minAmountOut);\\n if (balanceToken != 0) {\\n IERC20(tokenOut).safeTransfer(to, balanceToken);\\n }\\n }\\n\\n /// @notice Uses an external swapper\\n /// @param swapper Contracts implementing the logic of the swap\\n /// @param inToken Token used to do the swap\\n /// @param outToken Token wanted\\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\\n /// @param inTokenObtained Amount of `inToken` used for the swap\\n /// @param data Additional info for the specific swapper\\n function _swapper(\\n ISwapper swapper,\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory data\\n ) internal {\\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\\n }\\n\\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\\n /// @param inToken Token used as entrance of the swap\\n /// @param amount Amount of in token to swap\\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\\n function _swapOnUniswapV3(\\n IERC20 inToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n bytes memory path\\n ) internal returns (uint256 amountOut) {\\n // Approve transfer to the `uniswapV3Router`\\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\\n address uniRouter = address(uniswapV3Router);\\n _changeAllowance(IERC20(inToken), uniRouter, type(uint256).max);\\n amountOut = IUniswapV3Router(uniRouter).exactInput(\\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\\n );\\n }\\n\\n /// @notice Swaps an inToken to another token via 1Inch Router\\n /// @param payload Bytes needed for 1Inch router to process the swap\\n /// @dev The `payload` given is expected to be obtained from 1Inch API\\n function _swapOn1Inch(\\n IERC20 inToken,\\n uint256 minAmountOut,\\n bytes memory payload\\n ) internal returns (uint256 amountOut) {\\n // Approve transfer to the `oneInch` address\\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\\n address oneInchRouter = oneInch;\\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\\n //solhint-disable-next-line\\n (bool success, bytes memory result) = oneInchRouter.call(payload);\\n if (!success) _revertBytes(result);\\n\\n amountOut = abi.decode(result, (uint256));\\n _slippageCheck(amountOut, minAmountOut);\\n }\\n\\n /// @notice Mints `shares` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to mint shares from\\n /// @param shares Amount of shares to mint from the contract\\n /// @param to Address to which shares should be sent\\n /// @param maxAmountIn Max amount of assets used to mint\\n /// @return amountIn Amount of assets used to mint by `to`\\n function _mint4626(\\n IERC4626 savingsRate,\\n uint256 shares,\\n address to,\\n uint256 maxAmountIn\\n ) internal returns (uint256 amountIn) {\\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\\n }\\n\\n /// @notice Deposits `amount` to an ERC4626 contract\\n /// @param savingsRate The ERC4626 to deposit assets to\\n /// @param amount Amount of assets to deposit\\n /// @param to Address to which shares should be sent\\n /// @param minSharesOut Minimum amount of shares that `to` should received\\n /// @return sharesOut Amount of shares received by `to`\\n function _deposit4626(\\n IERC4626 savingsRate,\\n uint256 amount,\\n address to,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\\n }\\n\\n /// @notice Withdraws `amount` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to withdraw assets from\\n /// @param amount Amount of assets to withdraw\\n /// @param to Destination of assets\\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\\n /// @return sharesOut Amount of shares burnt\\n function _withdraw4626(\\n IERC4626 savingsRate,\\n uint256 amount,\\n address to,\\n uint256 maxSharesOut\\n ) internal returns (uint256 sharesOut) {\\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\\n }\\n\\n /// @notice Redeems `shares` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to redeem shares from\\n /// @param shares Amount of shares to redeem\\n /// @param to Destination of assets\\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\\n /// @return amountOut Amount of assets received by `to`\\n function _redeem4626(\\n IERC4626 savingsRate,\\n uint256 shares,\\n address to,\\n uint256 minAmountOut\\n ) internal returns (uint256 amountOut) {\\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\\n }\\n\\n /// @notice Allows to perform some specific actions for a chain\\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\\n\\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\\n\\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\\n\\n // ============================ GOVERNANCE FUNCTION ============================\\n\\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\\n modifier onlyGovernorOrGuardian() {\\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\\n _;\\n }\\n\\n /// @notice Sets a new `core` contract\\n function setCore(ICoreBorrow _core) external {\\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\\n core = ICoreBorrow(_core);\\n }\\n\\n /// @notice Changes allowances for different tokens\\n /// @param tokens Addresses of the tokens to allow\\n /// @param spenders Addresses to allow transfer\\n /// @param amounts Amounts to allow\\n function changeAllowance(\\n IERC20[] calldata tokens,\\n address[] calldata spenders,\\n uint256[] calldata amounts\\n ) external onlyGovernorOrGuardian {\\n uint256 tokensLength = tokens.length;\\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\\n for (uint256 i; i < tokensLength; ++i) {\\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\\n }\\n }\\n\\n /// @notice Sets a new router variable\\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\\n if (router == address(0)) revert ZeroAddress();\\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\\n else oneInch = router;\\n }\\n\\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\\n\\n /// @notice Changes allowance of this contract for a given token\\n /// @param token Address of the token to change allowance\\n /// @param spender Address to change the allowance of\\n /// @param amount Amount allowed\\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n // In case `currentAllowance < type(uint256).max / 2` and we want to increase it:\\n // Do nothing (to handle tokens that need reapprovals to 0 and save gas)\\n if (currentAllowance < amount && currentAllowance < type(uint256).max / 2) {\\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\\n } else if (currentAllowance > amount) {\\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\\n }\\n }\\n\\n /// @notice Transfer amount of the native token to the `to` address\\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\\n function _safeTransferNative(address to, uint256 amount) internal {\\n bool success;\\n //solhint-disable-next-line\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n if (!success) revert TransferFailed();\\n }\\n\\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\\n /// the calling address is well approved for all the vaults with which it is interacting\\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\\n /// with a vault are approved for this vault\\n function _parseVaultIDs(\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n address vaultManager,\\n address collateral\\n ) internal view returns (bytes[] memory) {\\n uint256 actionsBorrowLength = actionsBorrow.length;\\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\\n bool createVaultAction;\\n uint256 lastVaultID;\\n uint256 vaultIDLength;\\n for (uint256 i; i < actionsBorrowLength; ++i) {\\n uint256 vaultID;\\n // If there is a `createVault` action, the router should not worry about looking at\\n // next vaultIDs given equal to 0\\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\\n createVaultAction = true;\\n continue;\\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\\n // as collateral the full contract balance\\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\\n uint256 amount;\\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\\n if (amount == type(uint256).max)\\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\\n continue;\\n // There are different ways depending on the action to find the `vaultID` to parse\\n } else if (\\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\\n ) {\\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\\n vaultID = abi.decode(dataBorrow[i], (uint256));\\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\\n } else continue;\\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\\n // if there has not been any specific action\\n if (vaultID == 0) {\\n if (createVaultAction) {\\n continue;\\n } else {\\n // If we haven't stored the last `vaultID`, we need to fetch it\\n if (lastVaultID == 0) {\\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\\n }\\n vaultID = lastVaultID;\\n }\\n }\\n\\n // Check if this `vaultID` has already been verified\\n for (uint256 j; j < vaultIDLength; ++j) {\\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\\n // If yes, we continue to the next iteration\\n continue;\\n }\\n }\\n // Verify this new `vaultID` and add it to the list\\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\\n revert NotApprovedOrOwner();\\n }\\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\\n vaultIDLength += 1;\\n }\\n return dataBorrow;\\n }\\n\\n /// @notice Checks whether the amount obtained during a swap is not too small\\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\\n if (amount < thresholdAmount) revert TooSmallAmountOut();\\n }\\n\\n /// @notice Internal function used for error handling\\n function _revertBytes(bytes memory errMsg) internal pure {\\n if (errMsg.length != 0) {\\n //solhint-disable-next-line\\n assembly {\\n revert(add(32, errMsg), mload(errMsg))\\n }\\n }\\n revert InvalidReturnMessage();\\n }\\n}\\n\",\"keccak256\":\"0xd0cab24d7769f5bdb284b0c137883f09dc8b49c14c806261d6184c225ce31f37\",\"license\":\"GPL-3.0\"},\"contracts/implementations/base/AngleRouterBase.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"../../BaseAngleRouterSidechain.sol\\\";\\n\\n/// @title AngleRouterBase\\n/// @author Angle Core Team\\n/// @notice Router contract built specifially for Angle use cases on Base\\ncontract AngleRouterBase is BaseAngleRouterSidechain {\\n /// @inheritdoc BaseRouter\\n /// @dev There is no wCELO contract on CELO\\n function _getNativeWrapper() internal pure override returns (IWETH9) {\\n return IWETH9(0x4200000000000000000000000000000000000006);\\n }\\n}\\n\",\"keccak256\":\"0x42f11dbd0538aebd75b63177a2417bc82e01e983a25dcfcb60d3c5ef59ff10d5\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IAgTokenMultiChain.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title IAgTokenMultiChain\\n/// @author Angle Core Team\\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\\ninterface IAgTokenMultiChain {\\n function swapIn(\\n address bridgeToken,\\n uint256 amount,\\n address to\\n ) external returns (uint256);\\n\\n function swapOut(\\n address bridgeToken,\\n uint256 amount,\\n address to\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x535074b018a207b7a518dd6f5b2c7d127e27410dab239a0326177d663fa21e91\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ICoreBorrow.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title ICoreBorrow\\n/// @author Angle Core Team\\n/// @notice Interface for the `CoreBorrow` contract\\n\\ninterface ICoreBorrow {\\n /// @notice Checks whether an address is governor of the Angle Protocol or not\\n /// @param admin Address to check\\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\\n function isGovernor(address admin) external view returns (bool);\\n\\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\\n /// @param admin Address to check\\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\\n /// role by calling the `addGovernor` function\\n function isGovernorOrGuardian(address admin) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2414539c445977b04bc7e9adac2e5147364994dd74e5d7118b44824956de602c\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ILiquidityGauge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\ninterface ILiquidityGauge {\\n // solhint-disable-next-line\\n function staking_token() external returns (address stakingToken);\\n\\n // solhint-disable-next-line\\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\\n\\n function deposit(\\n uint256 _value,\\n address _addr,\\n // solhint-disable-next-line\\n bool _claim_rewards\\n ) external;\\n\\n // solhint-disable-next-line\\n function claim_rewards(address _addr) external;\\n\\n // solhint-disable-next-line\\n function claim_rewards(address _addr, address _receiver) external;\\n}\\n\",\"keccak256\":\"0x27144c21760603a4e441bb5eecf975ad7f71331ac0ba0a83352b280ccf734756\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ISwapper.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC20.sol\\\";\\n\\n/// @title ISwapper\\n/// @author Angle Core Team\\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\\ninterface ISwapper {\\n function swap(\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory data\\n ) external;\\n}\\n\",\"keccak256\":\"0x506f50d8447c2dc662bd844779cc66a407af07a91210612b956ef47abcc15776\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ITreasury.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title ITreasury\\n/// @author Angle Core Team\\n/// @notice Interface for the `Treasury` contract\\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\\n/// of this module\\ninterface ITreasury {\\n /// @notice Checks whether a given address has well been initialized in this contract\\n /// as a `VaultManager``\\n /// @param _vaultManager Address to check\\n /// @return Whether the address has been initialized or not\\n function isVaultManager(address _vaultManager) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x36bd50a0ab1c46503bb64b8d5777bf3b4fd2da0e2dcfe68c8a9702eb132eb3e2\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IVaultManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"./ITreasury.sol\\\";\\n\\n// ========================= Key Structs and Enums =============================\\n\\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\\n/// to the caller or associated addresses\\nstruct PaymentData {\\n // Stablecoin amount the contract should give\\n uint256 stablecoinAmountToGive;\\n // Stablecoin amount owed to the contract\\n uint256 stablecoinAmountToReceive;\\n // Collateral amount the contract should give\\n uint256 collateralAmountToGive;\\n // Collateral amount owed to the contract\\n uint256 collateralAmountToReceive;\\n}\\n\\n/// @notice Data stored to track someone's loan (or equivalently called position)\\nstruct Vault {\\n // Amount of collateral deposited in the vault\\n uint256 collateralAmount;\\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\\n uint256 normalizedDebt;\\n}\\n\\n/// @notice Actions possible when composing calls to the different entry functions proposed\\nenum ActionBorrowType {\\n createVault,\\n closeVault,\\n addCollateral,\\n removeCollateral,\\n repayDebt,\\n borrow,\\n getDebtIn,\\n permit\\n}\\n\\n// ========================= Interfaces =============================\\n\\n/// @title IVaultManagerFunctions\\n/// @author Angle Core Team\\n/// @notice Interface for the `VaultManager` contract\\n/// @dev This interface only contains functions of the contract which are called by other contracts\\n/// of this module (without getters)\\ninterface IVaultManagerFunctions {\\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\\n /// this function can perform any of the allowed actions in the order of their choice\\n /// @param actions Set of actions to perform\\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\\n /// should either be the `msg.sender` or be approved by the latter\\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\\n /// @return paymentData Struct containing the final transfers executed\\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\\n /// or computations (like `oracleValue`) are done only once\\n function angle(\\n ActionBorrowType[] memory actions,\\n bytes[] memory datas,\\n address from,\\n address to\\n ) external payable returns (PaymentData memory paymentData);\\n\\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\\n /// this function can perform any of the allowed actions in the order of their choice\\n /// @param actions Set of actions to perform\\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\\n /// should either be the `msg.sender` or be approved by the latter\\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\\n /// @param repayData Data to pass to the repayment contract in case of\\n /// @return paymentData Struct containing the final transfers executed\\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\\n /// or computations (like `oracleValue`) are done only once\\n function angle(\\n ActionBorrowType[] memory actions,\\n bytes[] memory datas,\\n address from,\\n address to,\\n address who,\\n bytes memory repayData\\n ) external payable returns (PaymentData memory paymentData);\\n\\n /// @notice Checks whether a given address is approved for a vault or owns this vault\\n /// @param spender Address for which vault ownership should be checked\\n /// @param vaultID ID of the vault to check\\n /// @return Whether the `spender` address owns or is approved for `vaultID`\\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\\n\\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\\n /// @param spender Address to give approval to\\n /// @param approved Whether to give or revoke the approval\\n /// @param deadline Deadline parameter for the signature to be valid\\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\\n function permit(\\n address owner,\\n address spender,\\n bool approved,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\\n/// @title IVaultManagerStorage\\n/// @author Angle Core Team\\n/// @notice Interface for the `VaultManager` contract\\n/// @dev This interface contains getters of the contract's public variables used by other contracts\\n/// of this module\\ninterface IVaultManagerStorage {\\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\\n function treasury() external view returns (ITreasury);\\n\\n /// @notice Reference to the collateral handled by this `VaultManager`\\n function collateral() external view returns (IERC20);\\n\\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\\n function vaultIDCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4cf6dc5e5b494165e4d9e524dca5c65f6307e5b005a62287c5e84f1539dc81f1\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/external/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Interface for WETH9\\ninterface IWETH9 is IERC20 {\\n /// @notice Deposit ether to get wrapped ether\\n function deposit() external payable;\\n\\n /// @notice Withdraw wrapped ether to get ether\\n function withdraw(uint256) external;\\n}\\n\",\"keccak256\":\"0xb109c1d668416c05f61d6edea2ec7a10b2f8b386fd51a59cc12f929c73d00424\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/external/uniswap/IUniswapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nstruct ExactInputParams {\\n bytes path;\\n address recipient;\\n uint256 deadline;\\n uint256 amountIn;\\n uint256 amountOutMinimum;\\n}\\n\\n/// @title Router token swapping functionality\\n/// @notice Functions for swapping tokens via Uniswap V3\\ninterface IUniswapV3Router {\\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\\n/// @title Router for price estimation functionality\\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\\n/// @dev This interface is only used for non critical elements of the protocol\\ninterface IUniswapV2Router {\\n /// @notice Given an input asset amount, returns the maximum output amount of the\\n /// other asset (accounting for fees) given reserves.\\n /// @param path Addresses of the pools used to get prices\\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\\n\\n function swapExactTokensForTokens(\\n uint256 swapAmount,\\n uint256 minExpected,\\n address[] calldata path,\\n address receiver,\\n uint256 swapDeadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x1908fcdc6ff78ad2250f6ccacc7129df464a648cb2a5f376bedbe506d058bb73\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b50600054610100900460ff1615808015620000335750600054600160ff909116105b8062000063575062000050306200013d60201b620018f81760201c565b15801562000063575060005460ff166001145b620000cb5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000ef576000805461ff0019166101001790555b801562000136576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b506200014c565b6001600160a01b03163b151590565b6143ad806200015c6000396000f3fe6080604052600436106100b55760003560e01c80638000963011610069578063848c48da1161004e578063848c48da146101d9578063b82c4dc1146101ec578063f2f4eb261461020c57600080fd5b8063800096301461019957806383f1d681146101b957600080fd5b80632c76d7a61161009a5780632c76d7a61461013957806342860d4b1461016657806359856d561461018657600080fd5b8063045c08d5146100c15780632026ffa31461011757600080fd5b366100bc57005b600080fd5b3480156100cd57600080fd5b506002546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561012357600080fd5b5061013761013236600461327b565b61023f565b005b34801561014557600080fd5b506001546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561017257600080fd5b506101376101813660046132d0565b610281565b6101376101943660046134e4565b6104ec565b3480156101a557600080fd5b506101376101b436600461366a565b610888565b3480156101c557600080fd5b506101376101d4366004613687565b610a3a565b6101376101e73660046136bc565b610bea565b3480156101f857600080fd5b50610137610207366004613751565b61175a565b34801561021857600080fd5b506000546100ee9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b61027c8383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061191492505050565b505050565b600054610100900460ff16158080156102a15750600054600160ff909116105b806102bb5750303b1580156102bb575060005460ff166001145b61034c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156103aa57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff84166103f7576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff80871662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff90921691909117909155600180548583167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600280549285169290911691909117905580156104e657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b855160005b818110156106b45787818151811061050b5761050b6137cc565b6020026020010151604001511561069f5787818151811061052e5761052e6137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd898381518110610567576105676137cc565b6020026020010151602001513060018c8681518110610588576105886137cc565b6020026020010151606001518d87815181106105a6576105a66137cc565b6020026020010151608001518e88815181106105c4576105c46137cc565b602002602001015160a001518f89815181106105e2576105e26137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561068257600080fd5b505af1158015610696573d6000803e3d6000fd5b505050506106a4565b6106b4565b6106ad8161382a565b90506104f1565b506106c28686868686610bea565b60005b8181101561087e578781815181106106df576106df6137cc565b60200260200101516040015161086e57878181518110610701576107016137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061073a5761073a6137cc565b6020026020010151602001513060008c868151811061075b5761075b6137cc565b6020026020010151606001518d8781518110610779576107796137cc565b6020026020010151608001518e8881518110610797576107976137cc565b602002602001015160a001518f89815181106107b5576107b56137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561085557600080fd5b505af1158015610869573d6000803e3d6000fd5b505050505b6108778161382a565b90506106c5565b5050505050505050565b6000546040517fe43581b80000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063e43581b890602401602060405180830381865afa1580156108fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091f9190613862565b15806109b657506040517fe43581b800000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff82169063e43581b890602401602060405180830381865afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613862565b155b156109ed576040517fee3675d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff90921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad19190613862565b610b07576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610b54576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060ff16600003610ba5576001805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790555050565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b5050565b845160005b81811015610da257868181518110610c0957610c096137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663d505accf888381518110610c4257610c426137cc565b602002602001015160200151308a8581518110610c6157610c616137cc565b6020026020010151604001518b8681518110610c7f57610c7f6137cc565b6020026020010151606001518c8781518110610c9d57610c9d6137cc565b6020026020010151608001518d8881518110610cbb57610cbb6137cc565b602002602001015160a001518e8981518110610cd957610cd96137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701526044860193909352606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b158015610d7957600080fd5b505af1158015610d8d573d6000803e3d6000fd5b5050505080610d9b9061382a565b9050610bef565b508360005b8181101561087e576000878783818110610dc357610dc36137cc565b9050602002016020810190610dd891906138ae565b601a811115610de957610de961387f565b03610f0c576000806000878785818110610e0557610e056137cc565b9050602002810190610e1791906138cf565b810190610e24919061393f565b9250925092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8103610ee2576040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190613980565b90505b610f0473ffffffffffffffffffffffffffffffffffffffff84163384846119d1565b50505061174a565b6001878783818110610f2057610f206137cc565b9050602002016020810190610f3591906138ae565b601a811115610f4657610f4661387f565b03610f5957610f53611aad565b5061174a565b6002878783818110610f6d57610f6d6137cc565b9050602002016020810190610f8291906138ae565b601a811115610f9357610f9361387f565b03610fda57600080868684818110610fad57610fad6137cc565b9050602002810190610fbf91906138cf565b810190610fcc9190613999565b91509150610f048282611b2a565b6003878783818110610fee57610fee6137cc565b905060200201602081019061100391906138ae565b601a8111156110145761101461387f565b03611060576000806000878785818110611030576110306137cc565b905060200281019061104291906138cf565b81019061104f91906139c9565b925092509250610f04838383611c71565b6004878783818110611074576110746137cc565b905060200201602081019061108991906138ae565b601a81111561109a5761109a61387f565b036110b057478015610f5357610f533382611d35565b60058787838181106110c4576110c46137cc565b90506020020160208101906110d991906138ae565b601a8111156110ea576110ea61387f565b0361114457600080600080888886818110611107576111076137cc565b905060200281019061111991906138cf565b8101906111269190613a8e565b935093509350935061113a84848484611d7a565b505050505061174a565b6006878783818110611158576111586137cc565b905060200201602081019061116d91906138ae565b601a81111561117e5761117e61387f565b036111d357600080600087878581811061119a5761119a6137cc565b90506020028101906111ac91906138cf565b8101906111b99190613af1565b9250925092506111ca838383611e84565b5050505061174a565b60078787838181106111e7576111e76137cc565b90506020020160208101906111fc91906138ae565b601a81111561120d5761120d61387f565b0361125b57600080868684818110611227576112276137cc565b905060200281019061123991906138cf565b8101906112469190613b4a565b915091506112548282611914565b505061174a565b600887878381811061126f5761126f6137cc565b905060200201602081019061128491906138ae565b601a8111156112955761129561387f565b036112e5576000806000808888868181106112b2576112b26137cc565b90506020028101906112c491906138cf565b8101906112d19190613bf9565b93509350935093506111ca84848484611f72565b60098787838181106112f9576112f96137cc565b905060200201602081019061130e91906138ae565b601a81111561131f5761131f61387f565b036113c25760008060008060008060008b8b89818110611341576113416137cc565b905060200281019061135391906138cf565b8101906113609190613d40565b965096509650965096509650965061137a8383888a611ffe565b91506113a787877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6113b5868484888886612669565b505050505050505061174a565b600a8787838181106113d6576113d66137cc565b90506020020160208101906113eb91906138ae565b601a8111156113fc576113fc61387f565b036114665760008060008060008060008b8b8981811061141e5761141e6137cc565b905060200281019061143091906138cf565b81019061143d9190613e0f565b965096509650965096509650965061145a8787878787878761273e565b5050505050505061174a565b600b87878381811061147a5761147a6137cc565b905060200201602081019061148f91906138ae565b601a8111156114a0576114a061387f565b0361152a5760008060008060008989878181106114bf576114bf6137cc565b90506020028101906114d191906138cf565b8101906114de9190613e9b565b9450945094509450945061151385857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b61151f848484846127d5565b50505050505061174a565b600c87878381811061153e5761153e6137cc565b905060200201602081019061155391906138ae565b601a8111156115645761156461387f565b036115e3576000806000806000898987818110611583576115836137cc565b905060200281019061159591906138cf565b8101906115a29190613e9b565b945094509450945094506115d785857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b61151f84848484612881565b600d8787838181106115f7576115f76137cc565b905060200201602081019061160c91906138ae565b601a81111561161d5761161d61387f565b0361166d5760008060008088888681811061163a5761163a6137cc565b905060200281019061164c91906138cf565b8101906116599190613ef6565b935093509350935061113a8484848461292b565b600e878783818110611681576116816137cc565b905060200201602081019061169691906138ae565b601a8111156116a7576116a761387f565b036116f7576000806000808888868181106116c4576116c46137cc565b90506020028101906116d691906138cf565b8101906116e39190613ef6565b935093509350935061113a84848484612993565b61174a87878381811061170c5761170c6137cc565b905060200201602081019061172191906138ae565b868684818110611733576117336137cc565b905060200281019061174591906138cf565b6129fe565b6117538161382a565b9050610da7565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa1580156117cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f19190613862565b611827576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806118375750808214155b1561186e576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561087e576118e888888381811061188e5761188e6137cc565b90506020020160208101906118a3919061366a565b8787848181106118b5576118b56137cc565b90506020020160208101906118ca919061366a565b8686858181106118dc576118dc6137cc565b9050602002013561252b565b6118f18161382a565b9050611871565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b805160005b818110156104e657828181518110611933576119336137cc565b60209081029190910101516040517f84e9bd7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906384e9bd7e90602401600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b50505050806119ca9061382a565b9050611919565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526104e69085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612a8d565b600073420000000000000000000000000000000000000673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b0b57600080fd5b505af1158015611b1f573d6000803e3d6000fd5b505050505034905090565b60007342000000000000000000000000000000000000066040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190613980565b9050611bdd8184612b99565b8015611c6b576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810182905273420000000000000000000000000000000000000690632e1a7d4d90602401600060405180830381600087803b158015611c4957600080fd5b505af1158015611c5d573d6000803e3d6000fd5b50505050611c6b8282611d35565b92915050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611cde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d029190613980565b9050611d0e8184612b99565b80156104e6576104e673ffffffffffffffffffffffffffffffffffffffff85168383612bd3565b600080600080600085875af190508061027c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60015460009073ffffffffffffffffffffffffffffffffffffffff16611dc186827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6040805160a0810182528481523060208201524281830152606081018790526080810186905290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169163c04b8d5991611e379190600401613fac565b6020604051808303816000875af1158015611e56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7a9190613980565b9695505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff16611ecb85827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6000808273ffffffffffffffffffffffffffffffffffffffff1685604051611ef39190614012565b6000604051808303816000865af19150503d8060008114611f30576040519150601f19603f3d011682016040523d82523d6000602084013e611f35565b606091505b509150915081611f4857611f4881612c29565b80806020019051810190611f5c9190613980565b9350611f688487612b99565b5050509392505050565b6040517f83df67470000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015282151560448301528316906383df674790606401600060405180830381600087803b158015611fea57600080fd5b505af115801561087e573d6000803e3d6000fd5b835160609060008167ffffffffffffffff81111561201e5761201e61331b565b604051908082528060200260200182016040528015612047578160200160208202803683370190505b5090506000806000805b85811015612519576000808c838151811061206e5761206e6137cc565b602002602001015160078111156120875761208761387f565b03612096576001945050612509565b60028c83815181106120aa576120aa6137cc565b602002602001015160078111156120c3576120c361387f565b036121da5760008b83815181106120dc576120dc6137cc565b60200260200101518060200190518101906120f7919061402e565b9092509050600181016121d3576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015612170573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121949190613980565b6040805160208101939093528201526060016040516020818303038152906040528c84815181106121c7576121c76137cc565b60200260200101819052505b5050612509565b60038c83815181106121ee576121ee6137cc565b602002602001015160078111156122075761220761387f565b148061223d575060058c8381518110612222576122226137cc565b6020026020010151600781111561223b5761223b61387f565b145b15612277578a8281518110612254576122546137cc565b602002602001015180602001905181019061226f919061402e565b50905061234e565b60018c838151811061228b5761228b6137cc565b602002602001015160078111156122a4576122a461387f565b036122dd578a82815181106122bb576122bb6137cc565b60200260200101518060200190518101906122d69190613980565b905061234e565b60068c83815181106122f1576122f16137cc565b6020026020010151600781111561230a5761230a61387f565b03612348578a8281518110612321576123216137cc565b602002602001015180602001905181019061233c9190614052565b5091925061234e915050565b50612509565b806000036123df5784156123625750612509565b836000036123dc578973ffffffffffffffffffffffffffffffffffffffff16633c2e941b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123d99190613980565b93505b50825b60005b8381101561241057818782815181106123fd576123fd6137cc565b5050506124098161382a565b90506123e2565b506040517f430c20810000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff8b169063430c208190604401602060405180830381865afa158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a69190613862565b6124dc576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808684815181106124ef576124ef6137cc565b6020908102919091010152612505600184614090565b9250505b6125128161382a565b9050612051565b5088955050505050505b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156125a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c59190613980565b905081811080156125ff57506125fc60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6140a3565b81105b15612635576126308361261283856140de565b73ffffffffffffffffffffffffffffffffffffffff87169190612c6a565b6104e6565b818111156104e6576104e68361264b84846140de565b73ffffffffffffffffffffffffffffffffffffffff87169190612d68565b6126946040518060800160405280600081526020016000815260200160008152602001600081525090565b6040517fde8fc69800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063de8fc698906126f0908990899033908a908a908a90600401614146565b6080604051808303816000875af115801561270f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127339190614246565b979650505050505050565b6040517fa5d4096b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063a5d4096b9061279a908990899089908990899089906004016142ac565b600060405180830381600087803b1580156127b457600080fd5b505af11580156127c8573d6000803e3d6000fd5b5050505050505050505050565b6040517f94bf804d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091612523918491908816906394bf804d906044015b6020604051808303816000875af1158015612855573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128799190613980565b925082612b99565b6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff838116602483015260009161252391871690636e553f65906044015b6020604051808303816000875af11580156128fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129229190613980565b91508183612b99565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916125239187169063ba087652906064016128df565b6040517fb460af940000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916125239184919088169063b460af9490606401612836565b601183601a811115612a1257612a1261387f565b03612a4b57600080808080612a2986880188614305565b94509450945094509450612a408585858585612ef5565b505050505050505050565b601283601a811115612a5f57612a5f61387f565b0361027c57600080808080612a7686880188614305565b94509450945094509450612a408585858585612fb1565b6000612aef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166130189092919063ffffffff16565b80519091501561027c5780806020019051810190612b0d9190613862565b61027c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610343565b80821015610be6576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261027c9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611a2b565b805115612c3857805181602001fd5b6040517fee418e3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d059190613980565b612d0f9190614090565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506104e69085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612dde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e029190613980565b905081811015612e94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610343565b60405173ffffffffffffffffffffffffffffffffffffffff841660248201528282036044820181905290612eee9086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b5050505050565b6040517f151dd75500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063151dd755906064015b6020604051808303816000875af1158015612f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9b9190613980565b9350612fa78484612b99565b5091949350505050565b6040517fd44ad63f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063d44ad63f90606401612f58565b60606130278484600085613031565b90505b9392505050565b6060824710156130c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610343565b73ffffffffffffffffffffffffffffffffffffffff85163b613141576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610343565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161316a9190614012565b60006040518083038185875af1925050503d80600081146131a7576040519150601f19603f3d011682016040523d82523d6000602084013e6131ac565b606091505b5091509150612733828286606083156131c657508161302a565b8251156131d65782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103439190614364565b73ffffffffffffffffffffffffffffffffffffffff8116811461322c57600080fd5b50565b60008083601f84011261324157600080fd5b50813567ffffffffffffffff81111561325957600080fd5b6020830191508360208260051b850101111561327457600080fd5b9250929050565b60008060006040848603121561329057600080fd5b833561329b8161320a565b9250602084013567ffffffffffffffff8111156132b757600080fd5b6132c38682870161322f565b9497909650939450505050565b6000806000606084860312156132e557600080fd5b83356132f08161320a565b925060208401356133008161320a565b915060408401356133108161320a565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561336d5761336d61331b565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156133ba576133ba61331b565b604052919050565b600067ffffffffffffffff8211156133dc576133dc61331b565b5060051b60200190565b801515811461322c57600080fd5b803560ff8116811461340557600080fd5b919050565b600082601f83011261341b57600080fd5b8135602061343061342b836133c2565b613373565b82815260e0928302850182019282820191908785111561344f57600080fd5b8387015b858110156134d75781818a03121561346b5760008081fd5b61347361334a565b813561347e8161320a565b81528186013561348d8161320a565b81870152604082810135908201526060808301359082015260806134b28184016133f4565b9082015260a0828101359082015260c080830135908201528452928401928101613453565b5090979650505050505050565b600080600080600080608087890312156134fd57600080fd5b863567ffffffffffffffff8082111561351557600080fd5b818901915089601f83011261352957600080fd5b8135602061353961342b836133c2565b82815260e09092028401810191818101908d84111561355757600080fd5b948201945b838610156135ee5760e0868f0312156135755760008081fd5b61357d61334a565b86356135888161320a565b8152868401356135978161320a565b818501526040878101356135aa816133e6565b90820152606087810135908201526135c4608088016133f4565b608082015260a0878101359082015260c08088013590820152825260e0909501949082019061355c565b9a50508a01359250508082111561360457600080fd5b6136108a838b0161340a565b9650604089013591508082111561362657600080fd5b6136328a838b0161322f565b9096509450606089013591508082111561364b57600080fd5b5061365889828a0161322f565b979a9699509497509295939492505050565b60006020828403121561367c57600080fd5b813561302a8161320a565b6000806040838503121561369a57600080fd5b82356136a58161320a565b91506136b3602084016133f4565b90509250929050565b6000806000806000606086880312156136d457600080fd5b853567ffffffffffffffff808211156136ec57600080fd5b6136f889838a0161340a565b9650602088013591508082111561370e57600080fd5b61371a89838a0161322f565b9096509450604088013591508082111561373357600080fd5b506137408882890161322f565b969995985093965092949392505050565b6000806000806000806060878903121561376a57600080fd5b863567ffffffffffffffff8082111561378257600080fd5b61378e8a838b0161322f565b909850965060208901359150808211156137a757600080fd5b6137b38a838b0161322f565b9096509450604089013591508082111561364b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361385b5761385b6137fb565b5060010190565b60006020828403121561387457600080fd5b815161302a816133e6565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6000602082840312156138c057600080fd5b8135601b811061302a57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261390457600080fd5b83018035915067ffffffffffffffff82111561391f57600080fd5b60200191503681900382131561327457600080fd5b80356134058161320a565b60008060006060848603121561395457600080fd5b833561395f8161320a565b9250602084013561396f8161320a565b929592945050506040919091013590565b60006020828403121561399257600080fd5b5051919050565b600080604083850312156139ac57600080fd5b8235915060208301356139be8161320a565b809150509250929050565b6000806000606084860312156139de57600080fd5b83356139e98161320a565b92506020840135915060408401356133108161320a565b600082601f830112613a1157600080fd5b813567ffffffffffffffff811115613a2b57613a2b61331b565b613a5c60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613373565b818152846020838601011115613a7157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613aa457600080fd5b8435613aaf8161320a565b93506020850135925060408501359150606085013567ffffffffffffffff811115613ad957600080fd5b613ae587828801613a00565b91505092959194509250565b600080600060608486031215613b0657600080fd5b8335613b118161320a565b925060208401359150604084013567ffffffffffffffff811115613b3457600080fd5b613b4086828701613a00565b9150509250925092565b60008060408385031215613b5d57600080fd5b8235613b688161320a565b915060208381013567ffffffffffffffff811115613b8557600080fd5b8401601f81018613613b9657600080fd5b8035613ba461342b826133c2565b81815260059190911b82018301908381019088831115613bc357600080fd5b928401925b82841015613bea578335613bdb8161320a565b82529284019290840190613bc8565b80955050505050509250929050565b60008060008060808587031215613c0f57600080fd5b8435613c1a8161320a565b9350602085013592506040850135613c318161320a565b91506060850135613c41816133e6565b939692955090935050565b600082601f830112613c5d57600080fd5b81356020613c6d61342b836133c2565b82815260059290921b84018101918181019086841115613c8c57600080fd5b8286015b84811015613cb557803560088110613ca85760008081fd5b8352918301918301613c90565b509695505050505050565b600082601f830112613cd157600080fd5b81356020613ce161342b836133c2565b82815260059290921b84018101918181019086841115613d0057600080fd5b8286015b84811015613cb557803567ffffffffffffffff811115613d245760008081fd5b613d328986838b0101613a00565b845250918301918301613d04565b600080600080600080600060e0888a031215613d5b57600080fd5b8735613d668161320a565b96506020880135613d768161320a565b9550613d8460408901613934565b9450613d9260608901613934565b9350608088013567ffffffffffffffff80821115613daf57600080fd5b613dbb8b838c01613c4c565b945060a08a0135915080821115613dd157600080fd5b613ddd8b838c01613cc0565b935060c08a0135915080821115613df357600080fd5b50613e008a828b01613a00565b91505092959891949750929550565b600080600080600080600060e0888a031215613e2a57600080fd5b8735613e358161320a565b96506020880135613e458161320a565b95506040880135613e558161320a565b94506060880135613e658161320a565b93506080880135925060a0880135915060c088013567ffffffffffffffff811115613e8f57600080fd5b613e008a828b01613a00565b600080600080600060a08688031215613eb357600080fd5b8535613ebe8161320a565b94506020860135613ece8161320a565b9350604086013592506060860135613ee58161320a565b949793965091946080013592915050565b60008060008060808587031215613f0c57600080fd5b8435613f178161320a565b9350602085013592506040850135613f2e8161320a565b9396929550929360600135925050565b60005b83811015613f59578181015183820152602001613f41565b50506000910152565b60008151808452613f7a816020860160208601613f3e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a06020840152613fc860c0840182613f62565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008251614024818460208701613f3e565b9190910192915050565b6000806040838503121561404157600080fd5b505080516020909101519092909150565b6000806000806080858703121561406857600080fd5b84519350602085015161407a8161320a565b6040860151606090960151949790965092505050565b80820180821115611c6b57611c6b6137fb565b6000826140d9577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115611c6b57611c6b6137fb565b600081518084526020808501808196508360051b8101915082860160005b85811015614139578284038952614127848351613f62565b9885019893509084019060010161410f565b5091979650505050505050565b60c0808252875190820181905260009060209060e0840190828b0184805b838110156141b5578251600881106141a3577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b85529385019391850191600101614164565b50505050838103828501526141ca818a6140f1565b9150506141ef604084018873ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff8616606084015273ffffffffffffffffffffffffffffffffffffffff8516608084015282810360a08401526142398185613f62565b9998505050505050505050565b60006080828403121561425857600080fd5b6040516080810181811067ffffffffffffffff8211171561427b5761427b61331b565b8060405250825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a08301526142f960c0830184613f62565b98975050505050505050565b600080600080600060a0868803121561431d57600080fd5b85356143288161320a565b945060208601356143388161320a565b9350604086013592506060860135915060808601356143568161320a565b809150509295509295909350565b60208152600061302a6020830184613f6256fea2646970667358221220352ef6e4ab56028c55a15c13d5cf59301a32cc63478bf38a1792942925ad755964736f6c63430008110033", + "deployedBytecode": "0x6080604052600436106100b55760003560e01c80638000963011610069578063848c48da1161004e578063848c48da146101d9578063b82c4dc1146101ec578063f2f4eb261461020c57600080fd5b8063800096301461019957806383f1d681146101b957600080fd5b80632c76d7a61161009a5780632c76d7a61461013957806342860d4b1461016657806359856d561461018657600080fd5b8063045c08d5146100c15780632026ffa31461011757600080fd5b366100bc57005b600080fd5b3480156100cd57600080fd5b506002546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561012357600080fd5b5061013761013236600461327b565b61023f565b005b34801561014557600080fd5b506001546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561017257600080fd5b506101376101813660046132d0565b610281565b6101376101943660046134e4565b6104ec565b3480156101a557600080fd5b506101376101b436600461366a565b610888565b3480156101c557600080fd5b506101376101d4366004613687565b610a3a565b6101376101e73660046136bc565b610bea565b3480156101f857600080fd5b50610137610207366004613751565b61175a565b34801561021857600080fd5b506000546100ee9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b61027c8383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061191492505050565b505050565b600054610100900460ff16158080156102a15750600054600160ff909116105b806102bb5750303b1580156102bb575060005460ff166001145b61034c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156103aa57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff84166103f7576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff80871662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff90921691909117909155600180548583167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600280549285169290911691909117905580156104e657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b855160005b818110156106b45787818151811061050b5761050b6137cc565b6020026020010151604001511561069f5787818151811061052e5761052e6137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd898381518110610567576105676137cc565b6020026020010151602001513060018c8681518110610588576105886137cc565b6020026020010151606001518d87815181106105a6576105a66137cc565b6020026020010151608001518e88815181106105c4576105c46137cc565b602002602001015160a001518f89815181106105e2576105e26137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561068257600080fd5b505af1158015610696573d6000803e3d6000fd5b505050506106a4565b6106b4565b6106ad8161382a565b90506104f1565b506106c28686868686610bea565b60005b8181101561087e578781815181106106df576106df6137cc565b60200260200101516040015161086e57878181518110610701576107016137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061073a5761073a6137cc565b6020026020010151602001513060008c868151811061075b5761075b6137cc565b6020026020010151606001518d8781518110610779576107796137cc565b6020026020010151608001518e8881518110610797576107976137cc565b602002602001015160a001518f89815181106107b5576107b56137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561085557600080fd5b505af1158015610869573d6000803e3d6000fd5b505050505b6108778161382a565b90506106c5565b5050505050505050565b6000546040517fe43581b80000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063e43581b890602401602060405180830381865afa1580156108fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091f9190613862565b15806109b657506040517fe43581b800000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff82169063e43581b890602401602060405180830381865afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613862565b155b156109ed576040517fee3675d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff90921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad19190613862565b610b07576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610b54576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060ff16600003610ba5576001805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790555050565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b5050565b845160005b81811015610da257868181518110610c0957610c096137cc565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663d505accf888381518110610c4257610c426137cc565b602002602001015160200151308a8581518110610c6157610c616137cc565b6020026020010151604001518b8681518110610c7f57610c7f6137cc565b6020026020010151606001518c8781518110610c9d57610c9d6137cc565b6020026020010151608001518d8881518110610cbb57610cbb6137cc565b602002602001015160a001518e8981518110610cd957610cd96137cc565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701526044860193909352606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b158015610d7957600080fd5b505af1158015610d8d573d6000803e3d6000fd5b5050505080610d9b9061382a565b9050610bef565b508360005b8181101561087e576000878783818110610dc357610dc36137cc565b9050602002016020810190610dd891906138ae565b601a811115610de957610de961387f565b03610f0c576000806000878785818110610e0557610e056137cc565b9050602002810190610e1791906138cf565b810190610e24919061393f565b9250925092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8103610ee2576040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190613980565b90505b610f0473ffffffffffffffffffffffffffffffffffffffff84163384846119d1565b50505061174a565b6001878783818110610f2057610f206137cc565b9050602002016020810190610f3591906138ae565b601a811115610f4657610f4661387f565b03610f5957610f53611aad565b5061174a565b6002878783818110610f6d57610f6d6137cc565b9050602002016020810190610f8291906138ae565b601a811115610f9357610f9361387f565b03610fda57600080868684818110610fad57610fad6137cc565b9050602002810190610fbf91906138cf565b810190610fcc9190613999565b91509150610f048282611b2a565b6003878783818110610fee57610fee6137cc565b905060200201602081019061100391906138ae565b601a8111156110145761101461387f565b03611060576000806000878785818110611030576110306137cc565b905060200281019061104291906138cf565b81019061104f91906139c9565b925092509250610f04838383611c71565b6004878783818110611074576110746137cc565b905060200201602081019061108991906138ae565b601a81111561109a5761109a61387f565b036110b057478015610f5357610f533382611d35565b60058787838181106110c4576110c46137cc565b90506020020160208101906110d991906138ae565b601a8111156110ea576110ea61387f565b0361114457600080600080888886818110611107576111076137cc565b905060200281019061111991906138cf565b8101906111269190613a8e565b935093509350935061113a84848484611d7a565b505050505061174a565b6006878783818110611158576111586137cc565b905060200201602081019061116d91906138ae565b601a81111561117e5761117e61387f565b036111d357600080600087878581811061119a5761119a6137cc565b90506020028101906111ac91906138cf565b8101906111b99190613af1565b9250925092506111ca838383611e84565b5050505061174a565b60078787838181106111e7576111e76137cc565b90506020020160208101906111fc91906138ae565b601a81111561120d5761120d61387f565b0361125b57600080868684818110611227576112276137cc565b905060200281019061123991906138cf565b8101906112469190613b4a565b915091506112548282611914565b505061174a565b600887878381811061126f5761126f6137cc565b905060200201602081019061128491906138ae565b601a8111156112955761129561387f565b036112e5576000806000808888868181106112b2576112b26137cc565b90506020028101906112c491906138cf565b8101906112d19190613bf9565b93509350935093506111ca84848484611f72565b60098787838181106112f9576112f96137cc565b905060200201602081019061130e91906138ae565b601a81111561131f5761131f61387f565b036113c25760008060008060008060008b8b89818110611341576113416137cc565b905060200281019061135391906138cf565b8101906113609190613d40565b965096509650965096509650965061137a8383888a611ffe565b91506113a787877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6113b5868484888886612669565b505050505050505061174a565b600a8787838181106113d6576113d66137cc565b90506020020160208101906113eb91906138ae565b601a8111156113fc576113fc61387f565b036114665760008060008060008060008b8b8981811061141e5761141e6137cc565b905060200281019061143091906138cf565b81019061143d9190613e0f565b965096509650965096509650965061145a8787878787878761273e565b5050505050505061174a565b600b87878381811061147a5761147a6137cc565b905060200201602081019061148f91906138ae565b601a8111156114a0576114a061387f565b0361152a5760008060008060008989878181106114bf576114bf6137cc565b90506020028101906114d191906138cf565b8101906114de9190613e9b565b9450945094509450945061151385857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b61151f848484846127d5565b50505050505061174a565b600c87878381811061153e5761153e6137cc565b905060200201602081019061155391906138ae565b601a8111156115645761156461387f565b036115e3576000806000806000898987818110611583576115836137cc565b905060200281019061159591906138cf565b8101906115a29190613e9b565b945094509450945094506115d785857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b61151f84848484612881565b600d8787838181106115f7576115f76137cc565b905060200201602081019061160c91906138ae565b601a81111561161d5761161d61387f565b0361166d5760008060008088888681811061163a5761163a6137cc565b905060200281019061164c91906138cf565b8101906116599190613ef6565b935093509350935061113a8484848461292b565b600e878783818110611681576116816137cc565b905060200201602081019061169691906138ae565b601a8111156116a7576116a761387f565b036116f7576000806000808888868181106116c4576116c46137cc565b90506020028101906116d691906138cf565b8101906116e39190613ef6565b935093509350935061113a84848484612993565b61174a87878381811061170c5761170c6137cc565b905060200201602081019061172191906138ae565b868684818110611733576117336137cc565b905060200281019061174591906138cf565b6129fe565b6117538161382a565b9050610da7565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa1580156117cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f19190613862565b611827576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806118375750808214155b1561186e576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561087e576118e888888381811061188e5761188e6137cc565b90506020020160208101906118a3919061366a565b8787848181106118b5576118b56137cc565b90506020020160208101906118ca919061366a565b8686858181106118dc576118dc6137cc565b9050602002013561252b565b6118f18161382a565b9050611871565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b805160005b818110156104e657828181518110611933576119336137cc565b60209081029190910101516040517f84e9bd7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906384e9bd7e90602401600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b50505050806119ca9061382a565b9050611919565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526104e69085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612a8d565b600073420000000000000000000000000000000000000673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b0b57600080fd5b505af1158015611b1f573d6000803e3d6000fd5b505050505034905090565b60007342000000000000000000000000000000000000066040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190613980565b9050611bdd8184612b99565b8015611c6b576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526004810182905273420000000000000000000000000000000000000690632e1a7d4d90602401600060405180830381600087803b158015611c4957600080fd5b505af1158015611c5d573d6000803e3d6000fd5b50505050611c6b8282611d35565b92915050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611cde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d029190613980565b9050611d0e8184612b99565b80156104e6576104e673ffffffffffffffffffffffffffffffffffffffff85168383612bd3565b600080600080600085875af190508061027c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60015460009073ffffffffffffffffffffffffffffffffffffffff16611dc186827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6040805160a0810182528481523060208201524281830152606081018790526080810186905290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169163c04b8d5991611e379190600401613fac565b6020604051808303816000875af1158015611e56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7a9190613980565b9695505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff16611ecb85827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61252b565b6000808273ffffffffffffffffffffffffffffffffffffffff1685604051611ef39190614012565b6000604051808303816000865af19150503d8060008114611f30576040519150601f19603f3d011682016040523d82523d6000602084013e611f35565b606091505b509150915081611f4857611f4881612c29565b80806020019051810190611f5c9190613980565b9350611f688487612b99565b5050509392505050565b6040517f83df67470000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015282151560448301528316906383df674790606401600060405180830381600087803b158015611fea57600080fd5b505af115801561087e573d6000803e3d6000fd5b835160609060008167ffffffffffffffff81111561201e5761201e61331b565b604051908082528060200260200182016040528015612047578160200160208202803683370190505b5090506000806000805b85811015612519576000808c838151811061206e5761206e6137cc565b602002602001015160078111156120875761208761387f565b03612096576001945050612509565b60028c83815181106120aa576120aa6137cc565b602002602001015160078111156120c3576120c361387f565b036121da5760008b83815181106120dc576120dc6137cc565b60200260200101518060200190518101906120f7919061402e565b9092509050600181016121d3576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015612170573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121949190613980565b6040805160208101939093528201526060016040516020818303038152906040528c84815181106121c7576121c76137cc565b60200260200101819052505b5050612509565b60038c83815181106121ee576121ee6137cc565b602002602001015160078111156122075761220761387f565b148061223d575060058c8381518110612222576122226137cc565b6020026020010151600781111561223b5761223b61387f565b145b15612277578a8281518110612254576122546137cc565b602002602001015180602001905181019061226f919061402e565b50905061234e565b60018c838151811061228b5761228b6137cc565b602002602001015160078111156122a4576122a461387f565b036122dd578a82815181106122bb576122bb6137cc565b60200260200101518060200190518101906122d69190613980565b905061234e565b60068c83815181106122f1576122f16137cc565b6020026020010151600781111561230a5761230a61387f565b03612348578a8281518110612321576123216137cc565b602002602001015180602001905181019061233c9190614052565b5091925061234e915050565b50612509565b806000036123df5784156123625750612509565b836000036123dc578973ffffffffffffffffffffffffffffffffffffffff16633c2e941b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123d99190613980565b93505b50825b60005b8381101561241057818782815181106123fd576123fd6137cc565b5050506124098161382a565b90506123e2565b506040517f430c20810000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff8b169063430c208190604401602060405180830381865afa158015612482573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a69190613862565b6124dc576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808684815181106124ef576124ef6137cc565b6020908102919091010152612505600184614090565b9250505b6125128161382a565b9050612051565b5088955050505050505b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156125a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c59190613980565b905081811080156125ff57506125fc60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6140a3565b81105b15612635576126308361261283856140de565b73ffffffffffffffffffffffffffffffffffffffff87169190612c6a565b6104e6565b818111156104e6576104e68361264b84846140de565b73ffffffffffffffffffffffffffffffffffffffff87169190612d68565b6126946040518060800160405280600081526020016000815260200160008152602001600081525090565b6040517fde8fc69800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063de8fc698906126f0908990899033908a908a908a90600401614146565b6080604051808303816000875af115801561270f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127339190614246565b979650505050505050565b6040517fa5d4096b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063a5d4096b9061279a908990899089908990899089906004016142ac565b600060405180830381600087803b1580156127b457600080fd5b505af11580156127c8573d6000803e3d6000fd5b5050505050505050505050565b6040517f94bf804d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091612523918491908816906394bf804d906044015b6020604051808303816000875af1158015612855573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128799190613980565b925082612b99565b6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff838116602483015260009161252391871690636e553f65906044015b6020604051808303816000875af11580156128fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129229190613980565b91508183612b99565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916125239187169063ba087652906064016128df565b6040517fb460af940000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916125239184919088169063b460af9490606401612836565b601183601a811115612a1257612a1261387f565b03612a4b57600080808080612a2986880188614305565b94509450945094509450612a408585858585612ef5565b505050505050505050565b601283601a811115612a5f57612a5f61387f565b0361027c57600080808080612a7686880188614305565b94509450945094509450612a408585858585612fb1565b6000612aef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166130189092919063ffffffff16565b80519091501561027c5780806020019051810190612b0d9190613862565b61027c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610343565b80821015610be6576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261027c9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611a2b565b805115612c3857805181602001fd5b6040517fee418e3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d059190613980565b612d0f9190614090565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506104e69085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612dde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e029190613980565b905081811015612e94576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610343565b60405173ffffffffffffffffffffffffffffffffffffffff841660248201528282036044820181905290612eee9086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b5050505050565b6040517f151dd75500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063151dd755906064015b6020604051808303816000875af1158015612f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f9b9190613980565b9350612fa78484612b99565b5091949350505050565b6040517fd44ad63f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063d44ad63f90606401612f58565b60606130278484600085613031565b90505b9392505050565b6060824710156130c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610343565b73ffffffffffffffffffffffffffffffffffffffff85163b613141576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610343565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161316a9190614012565b60006040518083038185875af1925050503d80600081146131a7576040519150601f19603f3d011682016040523d82523d6000602084013e6131ac565b606091505b5091509150612733828286606083156131c657508161302a565b8251156131d65782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103439190614364565b73ffffffffffffffffffffffffffffffffffffffff8116811461322c57600080fd5b50565b60008083601f84011261324157600080fd5b50813567ffffffffffffffff81111561325957600080fd5b6020830191508360208260051b850101111561327457600080fd5b9250929050565b60008060006040848603121561329057600080fd5b833561329b8161320a565b9250602084013567ffffffffffffffff8111156132b757600080fd5b6132c38682870161322f565b9497909650939450505050565b6000806000606084860312156132e557600080fd5b83356132f08161320a565b925060208401356133008161320a565b915060408401356133108161320a565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561336d5761336d61331b565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156133ba576133ba61331b565b604052919050565b600067ffffffffffffffff8211156133dc576133dc61331b565b5060051b60200190565b801515811461322c57600080fd5b803560ff8116811461340557600080fd5b919050565b600082601f83011261341b57600080fd5b8135602061343061342b836133c2565b613373565b82815260e0928302850182019282820191908785111561344f57600080fd5b8387015b858110156134d75781818a03121561346b5760008081fd5b61347361334a565b813561347e8161320a565b81528186013561348d8161320a565b81870152604082810135908201526060808301359082015260806134b28184016133f4565b9082015260a0828101359082015260c080830135908201528452928401928101613453565b5090979650505050505050565b600080600080600080608087890312156134fd57600080fd5b863567ffffffffffffffff8082111561351557600080fd5b818901915089601f83011261352957600080fd5b8135602061353961342b836133c2565b82815260e09092028401810191818101908d84111561355757600080fd5b948201945b838610156135ee5760e0868f0312156135755760008081fd5b61357d61334a565b86356135888161320a565b8152868401356135978161320a565b818501526040878101356135aa816133e6565b90820152606087810135908201526135c4608088016133f4565b608082015260a0878101359082015260c08088013590820152825260e0909501949082019061355c565b9a50508a01359250508082111561360457600080fd5b6136108a838b0161340a565b9650604089013591508082111561362657600080fd5b6136328a838b0161322f565b9096509450606089013591508082111561364b57600080fd5b5061365889828a0161322f565b979a9699509497509295939492505050565b60006020828403121561367c57600080fd5b813561302a8161320a565b6000806040838503121561369a57600080fd5b82356136a58161320a565b91506136b3602084016133f4565b90509250929050565b6000806000806000606086880312156136d457600080fd5b853567ffffffffffffffff808211156136ec57600080fd5b6136f889838a0161340a565b9650602088013591508082111561370e57600080fd5b61371a89838a0161322f565b9096509450604088013591508082111561373357600080fd5b506137408882890161322f565b969995985093965092949392505050565b6000806000806000806060878903121561376a57600080fd5b863567ffffffffffffffff8082111561378257600080fd5b61378e8a838b0161322f565b909850965060208901359150808211156137a757600080fd5b6137b38a838b0161322f565b9096509450604089013591508082111561364b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361385b5761385b6137fb565b5060010190565b60006020828403121561387457600080fd5b815161302a816133e6565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6000602082840312156138c057600080fd5b8135601b811061302a57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261390457600080fd5b83018035915067ffffffffffffffff82111561391f57600080fd5b60200191503681900382131561327457600080fd5b80356134058161320a565b60008060006060848603121561395457600080fd5b833561395f8161320a565b9250602084013561396f8161320a565b929592945050506040919091013590565b60006020828403121561399257600080fd5b5051919050565b600080604083850312156139ac57600080fd5b8235915060208301356139be8161320a565b809150509250929050565b6000806000606084860312156139de57600080fd5b83356139e98161320a565b92506020840135915060408401356133108161320a565b600082601f830112613a1157600080fd5b813567ffffffffffffffff811115613a2b57613a2b61331b565b613a5c60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613373565b818152846020838601011115613a7157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613aa457600080fd5b8435613aaf8161320a565b93506020850135925060408501359150606085013567ffffffffffffffff811115613ad957600080fd5b613ae587828801613a00565b91505092959194509250565b600080600060608486031215613b0657600080fd5b8335613b118161320a565b925060208401359150604084013567ffffffffffffffff811115613b3457600080fd5b613b4086828701613a00565b9150509250925092565b60008060408385031215613b5d57600080fd5b8235613b688161320a565b915060208381013567ffffffffffffffff811115613b8557600080fd5b8401601f81018613613b9657600080fd5b8035613ba461342b826133c2565b81815260059190911b82018301908381019088831115613bc357600080fd5b928401925b82841015613bea578335613bdb8161320a565b82529284019290840190613bc8565b80955050505050509250929050565b60008060008060808587031215613c0f57600080fd5b8435613c1a8161320a565b9350602085013592506040850135613c318161320a565b91506060850135613c41816133e6565b939692955090935050565b600082601f830112613c5d57600080fd5b81356020613c6d61342b836133c2565b82815260059290921b84018101918181019086841115613c8c57600080fd5b8286015b84811015613cb557803560088110613ca85760008081fd5b8352918301918301613c90565b509695505050505050565b600082601f830112613cd157600080fd5b81356020613ce161342b836133c2565b82815260059290921b84018101918181019086841115613d0057600080fd5b8286015b84811015613cb557803567ffffffffffffffff811115613d245760008081fd5b613d328986838b0101613a00565b845250918301918301613d04565b600080600080600080600060e0888a031215613d5b57600080fd5b8735613d668161320a565b96506020880135613d768161320a565b9550613d8460408901613934565b9450613d9260608901613934565b9350608088013567ffffffffffffffff80821115613daf57600080fd5b613dbb8b838c01613c4c565b945060a08a0135915080821115613dd157600080fd5b613ddd8b838c01613cc0565b935060c08a0135915080821115613df357600080fd5b50613e008a828b01613a00565b91505092959891949750929550565b600080600080600080600060e0888a031215613e2a57600080fd5b8735613e358161320a565b96506020880135613e458161320a565b95506040880135613e558161320a565b94506060880135613e658161320a565b93506080880135925060a0880135915060c088013567ffffffffffffffff811115613e8f57600080fd5b613e008a828b01613a00565b600080600080600060a08688031215613eb357600080fd5b8535613ebe8161320a565b94506020860135613ece8161320a565b9350604086013592506060860135613ee58161320a565b949793965091946080013592915050565b60008060008060808587031215613f0c57600080fd5b8435613f178161320a565b9350602085013592506040850135613f2e8161320a565b9396929550929360600135925050565b60005b83811015613f59578181015183820152602001613f41565b50506000910152565b60008151808452613f7a816020860160208601613f3e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a06020840152613fc860c0840182613f62565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008251614024818460208701613f3e565b9190910192915050565b6000806040838503121561404157600080fd5b505080516020909101519092909150565b6000806000806080858703121561406857600080fd5b84519350602085015161407a8161320a565b6040860151606090960151949790965092505050565b80820180821115611c6b57611c6b6137fb565b6000826140d9577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115611c6b57611c6b6137fb565b600081518084526020808501808196508360051b8101915082860160005b85811015614139578284038952614127848351613f62565b9885019893509084019060010161410f565b5091979650505050505050565b60c0808252875190820181905260009060209060e0840190828b0184805b838110156141b5578251600881106141a3577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b85529385019391850191600101614164565b50505050838103828501526141ca818a6140f1565b9150506141ef604084018873ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff8616606084015273ffffffffffffffffffffffffffffffffffffffff8516608084015282810360a08401526142398185613f62565b9998505050505050505050565b60006080828403121561425857600080fd5b6040516080810181811067ffffffffffffffff8211171561427b5761427b61331b565b8060405250825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a08301526142f960c0830184613f62565b98975050505050505050565b600080600080600060a0868803121561431d57600080fd5b85356143288161320a565b945060208601356143388161320a565b9350604086013592506060860135915060808601356143568161320a565b809150509295509295909350565b60208152600061302a6020830184613f6256fea2646970667358221220352ef6e4ab56028c55a15c13d5cf59301a32cc63478bf38a1792942925ad755964736f6c63430008110033", + "devdoc": { + "author": "Angle Core Team", + "kind": "dev", + "methods": { + "changeAllowance(address[],address[],uint256[])": { + "params": { + "amounts": "Amounts to allow", + "spenders": "Addresses to allow transfer", + "tokens": "Addresses of the tokens to allow" + } + }, + "claimRewards(address,address[])": { + "details": "If the caller wants to send the rewards to another account it first needs to call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`", + "params": { + "gaugeUser": "Address for which to fetch the rewards from the gauges", + "liquidityGauges": "Gauges to claim on" + } + }, + "mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "details": "With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol does not verify the payload given and cannot check that the swap performed by users actually gives the desired out token: in this case funds may be made accessible to anyone on this contract if the concerned users do not perform a sweep action on these tokens", + "params": { + "actions": "List of actions to be performed by the router (in order of execution)", + "data": "Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters for a given action are stored", + "paramsPermit": "Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract with tokens that do not support permit should approve the contract for these tokens prior to interacting with it" + } + }, + "mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "details": "In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures to revoke approvalsThe router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this is just an option", + "params": { + "paramsPermitVaultManager": "Parameters to sign permit to give allowance to the router for a `VaultManager` contract" + } + } + }, + "title": "AngleRouterBase", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "changeAllowance(address[],address[],uint256[])": { + "notice": "Changes allowances for different tokens" + }, + "claimRewards(address,address[])": { + "notice": "Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple gauges at once" + }, + "core()": { + "notice": "Core address handling access control" + }, + "initializeRouter(address,address,address)": { + "notice": "Deploys the router contract on a chain" + }, + "mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "notice": "Allows composable calls to different functions within the protocol" + }, + "mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "notice": "Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing actions and then revoking this approval after these actions" + }, + "oneInch()": { + "notice": "Address of 1Inch router used for swaps" + }, + "setCore(address)": { + "notice": "Sets a new `core` contract" + }, + "setRouter(address,uint8)": { + "notice": "Sets a new router variable" + }, + "uniswapV3Router()": { + "notice": "Address of the router used for swaps" + } + }, + "notice": "Router contract built specifially for Angle use cases on Base", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 6, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 9, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1544, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "core", + "offset": 2, + "slot": "0", + "type": "t_contract(ICoreBorrow)3549" + }, + { + "astId": 1548, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "uniswapV3Router", + "offset": 0, + "slot": "1", + "type": "t_contract(IUniswapV3Router)3779" + }, + { + "astId": 1551, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "oneInch", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 1555, + "contract": "contracts/implementations/base/AngleRouterBase.sol:AngleRouterBase", + "label": "__gap", + "offset": 0, + "slot": "3", + "type": "t_array(t_uint256)47_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(ICoreBorrow)3549": { + "encoding": "inplace", + "label": "contract ICoreBorrow", + "numberOfBytes": "20" + }, + "t_contract(IUniswapV3Router)3779": { + "encoding": "inplace", + "label": "contract IUniswapV3Router", + "numberOfBytes": "20" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/deployments/base/solcInputs/382e5f7965175dcf029b988f27abf9db.json b/deployments/base/solcInputs/382e5f7965175dcf029b988f27abf9db.json new file mode 100644 index 0000000..fc189d4 --- /dev/null +++ b/deployments/base/solcInputs/382e5f7965175dcf029b988f27abf9db.json @@ -0,0 +1,286 @@ +{ + "language": "Solidity", + "sources": { + "contracts/BaseAngleRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./interfaces/IAgTokenMultiChain.sol\";\nimport \"./BaseRouter.sol\";\n\n/// @title BaseAngleRouterSidechain\n/// @author Angle Core Team\n/// @notice Extension of the `BaseRouter` contract for sidechains\nabstract contract BaseAngleRouterSidechain is BaseRouter {\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\n /// gauges at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @dev If the caller wants to send the rewards to another account it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\n _claimRewards(gaugeUser, liquidityGauges);\n }\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.swapIn) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\n } else if (action == ActionType.swapOut) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\n }\n }\n\n /// @notice Wraps a bridge token to its corresponding canonical version\n function _swapIn(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n\n /// @notice Unwraps a canonical token for one of its bridge version\n function _swapOut(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n}\n" + }, + "contracts/interfaces/IAgTokenMultiChain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IAgTokenMultiChain\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\ninterface IAgTokenMultiChain {\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n}\n" + }, + "contracts/BaseRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n * █ \n ***** ▓▓▓ \n * ▓▓▓▓▓▓▓ \n * ///. ▓▓▓▓▓▓▓▓▓▓▓▓▓ \n ***** //////// ▓▓▓▓▓▓▓ \n * ///////////// ▓▓▓ \n ▓▓ ////////////////// █ ▓▓ \n ▓▓ ▓▓ /////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ //////////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ /////////▓▓▓///////▓▓▓///////// ▓▓ ▓▓ \n ▓▓ ,////////////////////////////////////// ▓▓ ▓▓ \n ▓▓ ////////////////////////////////////////// ▓▓ \n ▓▓ //////////////////////▓▓▓▓///////////////////// \n ,//////////////////////////////////////////////////// \n .////////////////////////////////////////////////////////// \n .//////////////////////////██.,//////////////////////////█ \n .//////////////////////████..,./////////////////////██ \n ...////////////////███████.....,.////////////////███ \n ,.,////////////████████ ........,///////////████ \n .,.,//////█████████ ,.......///////████ \n ,..//████████ ........./████ \n ..,██████ .....,███ \n .██ ,.,█ \n \n \n \n ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ \n ▓▓▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ▓▓▓▓ \n ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓▓▓▓ \n ▓▓▓ ▓▓ ▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ \n*/\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\nimport \"./interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./interfaces/external/IWETH9.sol\";\nimport \"./interfaces/ICoreBorrow.sol\";\nimport \"./interfaces/ILiquidityGauge.sol\";\nimport \"./interfaces/ISwapper.sol\";\nimport \"./interfaces/IVaultManager.sol\";\n\n// ============================== STRUCTS AND ENUM =============================\n\n/// @notice Action types\nenum ActionType {\n transfer,\n wrapNative,\n unwrapNative,\n sweep,\n sweepNative,\n uniswapV3,\n oneInch,\n claimRewards,\n gaugeDeposit,\n borrower,\n swapper,\n mint4626,\n deposit4626,\n redeem4626,\n withdraw4626,\n // Deprecated\n prepareRedeemSavingsRate,\n // Deprecated\n claimRedeemSavingsRate,\n swapIn,\n swapOut,\n claimWeeklyInterest,\n withdraw,\n // Deprecated\n mint,\n deposit,\n // Deprecated\n openPerpetual,\n // Deprecated\n addToPerpetual,\n veANGLEDeposit,\n claimRewardsWithPerps\n}\n\n/// @notice Data needed to get permits\nstruct PermitType {\n address token;\n address owner;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @notice Data to grant permit to the router for a vault\nstruct PermitVaultManagerType {\n address vaultManager;\n address owner;\n bool approved;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @title BaseRouter\n/// @author Angle Core Team\n/// @notice Base contract that Angle router contracts on different chains should override\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\nabstract contract BaseRouter is Initializable {\n using SafeERC20 for IERC20;\n\n // ================================= REFERENCES ================================\n\n /// @notice Core address handling access control\n ICoreBorrow public core;\n /// @notice Address of the router used for swaps\n IUniswapV3Router public uniswapV3Router;\n /// @notice Address of 1Inch router used for swaps\n address public oneInch;\n\n uint256[47] private __gap;\n\n // ============================== EVENTS / ERRORS ==============================\n\n error IncompatibleLengths();\n error InvalidReturnMessage();\n error NotApprovedOrOwner();\n error NotGovernor();\n error NotGovernorOrGuardian();\n error TooSmallAmountOut();\n error TransferFailed();\n error ZeroAddress();\n\n /// @notice Deploys the router contract on a chain\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\n if (_core == address(0)) revert ZeroAddress();\n core = ICoreBorrow(_core);\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\n oneInch = _oneInch;\n }\n\n constructor() initializer {}\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Allows composable calls to different functions within the protocol\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\n /// @param actions List of actions to be performed by the router (in order of execution)\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\n /// for a given action are stored\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\n /// do not perform a sweep action on these tokens\n function mixer(\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) public payable virtual {\n // If all tokens have already been approved, there's no need for this step\n uint256 permitsLength = paramsPermit.length;\n for (uint256 i; i < permitsLength; ++i) {\n IERC20Permit(paramsPermit[i].token).permit(\n paramsPermit[i].owner,\n address(this),\n paramsPermit[i].value,\n paramsPermit[i].deadline,\n paramsPermit[i].v,\n paramsPermit[i].r,\n paramsPermit[i].s\n );\n }\n // Performing actions one after the others\n uint256 actionsLength = actions.length;\n for (uint256 i; i < actionsLength; ++i) {\n if (actions[i] == ActionType.transfer) {\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\n } else if (actions[i] == ActionType.wrapNative) {\n _wrapNative();\n } else if (actions[i] == ActionType.unwrapNative) {\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\n _unwrapNative(minAmountOut, to);\n } else if (actions[i] == ActionType.sweep) {\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\n _sweep(tokenOut, minAmountOut, to);\n } else if (actions[i] == ActionType.sweepNative) {\n uint256 routerBalance = address(this).balance;\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\n } else if (actions[i] == ActionType.uniswapV3) {\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\n data[i],\n (address, uint256, uint256, bytes)\n );\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\n } else if (actions[i] == ActionType.oneInch) {\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\n data[i],\n (address, uint256, bytes)\n );\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\n } else if (actions[i] == ActionType.claimRewards) {\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\n _claimRewards(user, claimLiquidityGauges);\n } else if (actions[i] == ActionType.gaugeDeposit) {\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\n data[i],\n (address, uint256, address, bool)\n );\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\n } else if (actions[i] == ActionType.borrower) {\n (\n address collateral,\n address vaultManager,\n address to,\n address who,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n bytes memory repayData\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\n } else if (actions[i] == ActionType.swapper) {\n (\n ISwapper swapperContract,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory payload\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\n } else if (actions[i] == ActionType.mint4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _mint4626(savingsRate, shares, to, maxAmountIn);\n } else if (actions[i] == ActionType.deposit4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _deposit4626(savingsRate, amount, to, minSharesOut);\n } else if (actions[i] == ActionType.redeem4626) {\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _redeem4626(savingsRate, shares, to, minAmountOut);\n } else if (actions[i] == ActionType.withdraw4626) {\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\n } else {\n _chainSpecificAction(actions[i], data[i]);\n }\n }\n }\n\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\n /// actions and then revoking this approval after these actions\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\n /// to revoke approvals\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\n /// is just an option\n function mixerVaultManagerPermit(\n PermitVaultManagerType[] memory paramsPermitVaultManager,\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) external payable virtual {\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n true,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n } else break;\n }\n mixer(paramsPermit, actions, data);\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\n // too deep\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (!paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n false,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n }\n }\n }\n\n receive() external payable {}\n\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\n\n /// @notice Wraps the native token of a chain to its wrapped version\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\n /// @dev The amount to wrap is to be specified in the `msg.value`\n function _wrapNative() internal virtual returns (uint256) {\n _getNativeWrapper().deposit{ value: msg.value }();\n return msg.value;\n }\n\n /// @notice Unwraps the wrapped version of a token to the native chain token\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\n amount = _getNativeWrapper().balanceOf(address(this));\n _slippageCheck(amount, minAmountOut);\n if (amount != 0) {\n _getNativeWrapper().withdraw(amount);\n _safeTransferNative(to, amount);\n }\n return amount;\n }\n\n /// @notice Internal version of the `claimRewards` function\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\n uint256 gaugesLength = liquidityGauges.length;\n for (uint256 i; i < gaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n }\n\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\n /// @param vaultManager Address of the vault to perform actions on\n /// @param actionsBorrow Actions type to perform on the vaultManager\n /// @param dataBorrow Data needed for each actions\n /// @param to Address to send the funds to\n /// @param who Swapper address to handle repayments\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\n function _angleBorrower(\n address vaultManager,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address to,\n address who,\n bytes memory repayData\n ) internal virtual returns (PaymentData memory paymentData) {\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\n }\n\n /// @notice Allows to deposit tokens into a gauge\n /// @param user Address on behalf of which deposits should be made in the gauge\n /// @param amount Amount to stake\n /// @param gauge Liquidity gauge to stake in\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\n /// @dev The function will revert if the gauge has not already been approved by the contract\n function _gaugeDeposit(\n address user,\n uint256 amount,\n ILiquidityGauge gauge,\n bool shouldClaimRewards\n ) internal virtual {\n gauge.deposit(amount, user, shouldClaimRewards);\n }\n\n /// @notice Sweeps tokens from the router contract\n /// @param tokenOut Token to sweep\n /// @param minAmountOut Minimum amount of tokens to recover\n /// @param to Address to which tokens should be sent\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\n _slippageCheck(balanceToken, minAmountOut);\n if (balanceToken != 0) {\n IERC20(tokenOut).safeTransfer(to, balanceToken);\n }\n }\n\n /// @notice Uses an external swapper\n /// @param swapper Contracts implementing the logic of the swap\n /// @param inToken Token used to do the swap\n /// @param outToken Token wanted\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\n /// @param inTokenObtained Amount of `inToken` used for the swap\n /// @param data Additional info for the specific swapper\n function _swapper(\n ISwapper swapper,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) internal {\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\n }\n\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\n /// @param inToken Token used as entrance of the swap\n /// @param amount Amount of in token to swap\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\n function _swapOnUniswapV3(\n IERC20 inToken,\n uint256 amount,\n uint256 minAmountOut,\n bytes memory path\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `uniswapV3Router`\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address uniRouter = address(uniswapV3Router);\n uint256 currentAllowance = IERC20(inToken).allowance(address(this), uniRouter);\n if (currentAllowance < amount)\n IERC20(inToken).safeIncreaseAllowance(uniRouter, type(uint256).max - currentAllowance);\n amountOut = IUniswapV3Router(uniRouter).exactInput(\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\n );\n }\n\n /// @notice Swaps an inToken to another token via 1Inch Router\n /// @param payload Bytes needed for 1Inch router to process the swap\n /// @dev The `payload` given is expected to be obtained from 1Inch API\n function _swapOn1Inch(\n IERC20 inToken,\n uint256 minAmountOut,\n bytes memory payload\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `oneInch` address\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address oneInchRouter = oneInch;\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\n //solhint-disable-next-line\n (bool success, bytes memory result) = oneInchRouter.call(payload);\n if (!success) _revertBytes(result);\n\n amountOut = abi.decode(result, (uint256));\n _slippageCheck(amountOut, minAmountOut);\n }\n\n /// @notice Mints `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to mint shares from\n /// @param shares Amount of shares to mint from the contract\n /// @param to Address to which shares should be sent\n /// @param maxAmountIn Max amount of assets used to mint\n /// @return amountIn Amount of assets used to mint by `to`\n function _mint4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 maxAmountIn\n ) internal returns (uint256 amountIn) {\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\n }\n\n /// @notice Deposits `amount` to an ERC4626 contract\n /// @param savingsRate The ERC4626 to deposit assets to\n /// @param amount Amount of assets to deposit\n /// @param to Address to which shares should be sent\n /// @param minSharesOut Minimum amount of shares that `to` should received\n /// @return sharesOut Amount of shares received by `to`\n function _deposit4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\n }\n\n /// @notice Withdraws `amount` from an ERC4626 contract\n /// @param savingsRate ERC4626 to withdraw assets from\n /// @param amount Amount of assets to withdraw\n /// @param to Destination of assets\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\n /// @return sharesOut Amount of shares burnt\n function _withdraw4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 maxSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\n }\n\n /// @notice Redeems `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to redeem shares from\n /// @param shares Amount of shares to redeem\n /// @param to Destination of assets\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\n /// @return amountOut Amount of assets received by `to`\n function _redeem4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 minAmountOut\n ) internal returns (uint256 amountOut) {\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\n }\n\n /// @notice Allows to perform some specific actions for a chain\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\n\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\n\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\n\n // ============================ GOVERNANCE FUNCTION ============================\n\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\n modifier onlyGovernorOrGuardian() {\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n _;\n }\n\n /// @notice Sets a new `core` contract\n function setCore(ICoreBorrow _core) external {\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\n core = ICoreBorrow(_core);\n }\n\n /// @notice Changes allowances for different tokens\n /// @param tokens Addresses of the tokens to allow\n /// @param spenders Addresses to allow transfer\n /// @param amounts Amounts to allow\n function changeAllowance(\n IERC20[] calldata tokens,\n address[] calldata spenders,\n uint256[] calldata amounts\n ) external onlyGovernorOrGuardian {\n uint256 tokensLength = tokens.length;\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\n for (uint256 i; i < tokensLength; ++i) {\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\n }\n }\n\n /// @notice Sets a new router variable\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\n if (router == address(0)) revert ZeroAddress();\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\n else oneInch = router;\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Changes allowance of this contract for a given token\n /// @param token Address of the token to change allowance\n /// @param spender Address to change the allowance of\n /// @param amount Amount allowed\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < amount) {\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\n } else if (currentAllowance > amount) {\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\n }\n }\n\n /// @notice Transfer amount of the native token to the `to` address\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\n function _safeTransferNative(address to, uint256 amount) internal {\n bool success;\n //solhint-disable-next-line\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n if (!success) revert TransferFailed();\n }\n\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\n /// the calling address is well approved for all the vaults with which it is interacting\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\n /// with a vault are approved for this vault\n function _parseVaultIDs(\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address vaultManager,\n address collateral\n ) internal view returns (bytes[] memory) {\n uint256 actionsBorrowLength = actionsBorrow.length;\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\n bool createVaultAction;\n uint256 lastVaultID;\n uint256 vaultIDLength;\n for (uint256 i; i < actionsBorrowLength; ++i) {\n uint256 vaultID;\n // If there is a `createVault` action, the router should not worry about looking at\n // next vaultIDs given equal to 0\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\n createVaultAction = true;\n continue;\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\n // as collateral the full contract balance\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\n uint256 amount;\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\n if (amount == type(uint256).max)\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\n continue;\n // There are different ways depending on the action to find the `vaultID` to parse\n } else if (\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\n ) {\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\n vaultID = abi.decode(dataBorrow[i], (uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\n } else continue;\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\n // if there has not been any specific action\n if (vaultID == 0) {\n if (createVaultAction) {\n continue;\n } else {\n // If we haven't stored the last `vaultID`, we need to fetch it\n if (lastVaultID == 0) {\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\n }\n vaultID = lastVaultID;\n }\n }\n\n // Check if this `vaultID` has already been verified\n for (uint256 j; j < vaultIDLength; ++j) {\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\n // If yes, we continue to the next iteration\n continue;\n }\n }\n // Verify this new `vaultID` and add it to the list\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\n revert NotApprovedOrOwner();\n }\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\n vaultIDLength += 1;\n }\n return dataBorrow;\n }\n\n /// @notice Checks whether the amount obtained during a swap is not too small\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\n if (amount < thresholdAmount) revert TooSmallAmountOut();\n }\n\n /// @notice Internal function used for error handling\n function _revertBytes(bytes memory errMsg) internal pure {\n if (errMsg.length != 0) {\n //solhint-disable-next-line\n assembly {\n revert(add(32, errMsg), mload(errMsg))\n }\n }\n revert InvalidReturnMessage();\n }\n}\n" + }, + "contracts/interfaces/external/uniswap/IUniswapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nstruct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n}\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IUniswapV3Router {\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\n/// @title Router for price estimation functionality\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\n/// @dev This interface is only used for non critical elements of the protocol\ninterface IUniswapV2Router {\n /// @notice Given an input asset amount, returns the maximum output amount of the\n /// other asset (accounting for fees) given reserves.\n /// @param path Addresses of the pools used to get prices\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 swapAmount,\n uint256 minExpected,\n address[] calldata path,\n address receiver,\n uint256 swapDeadline\n ) external;\n}\n" + }, + "contracts/interfaces/external/IWETH9.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n /// @notice Deposit ether to get wrapped ether\n function deposit() external payable;\n\n /// @notice Withdraw wrapped ether to get ether\n function withdraw(uint256) external;\n}\n" + }, + "contracts/interfaces/ICoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ICoreBorrow\n/// @author Angle Core Team\n/// @notice Interface for the `CoreBorrow` contract\n\ninterface ICoreBorrow {\n /// @notice Checks whether an address is governor of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\n function isGovernor(address admin) external view returns (bool);\n\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\n /// role by calling the `addGovernor` function\n function isGovernorOrGuardian(address admin) external view returns (bool);\n}\n" + }, + "contracts/interfaces/ILiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface ILiquidityGauge {\n // solhint-disable-next-line\n function staking_token() external returns (address stakingToken);\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external;\n}\n" + }, + "contracts/interfaces/ISwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\n\n/// @title ISwapper\n/// @author Angle Core Team\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\ninterface ISwapper {\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) external;\n}\n" + }, + "contracts/interfaces/IVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./ITreasury.sol\";\n\n// ========================= Key Structs and Enums =============================\n\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\n/// to the caller or associated addresses\nstruct PaymentData {\n // Stablecoin amount the contract should give\n uint256 stablecoinAmountToGive;\n // Stablecoin amount owed to the contract\n uint256 stablecoinAmountToReceive;\n // Collateral amount the contract should give\n uint256 collateralAmountToGive;\n // Collateral amount owed to the contract\n uint256 collateralAmountToReceive;\n}\n\n/// @notice Data stored to track someone's loan (or equivalently called position)\nstruct Vault {\n // Amount of collateral deposited in the vault\n uint256 collateralAmount;\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\n uint256 normalizedDebt;\n}\n\n/// @notice Actions possible when composing calls to the different entry functions proposed\nenum ActionBorrowType {\n createVault,\n closeVault,\n addCollateral,\n removeCollateral,\n repayDebt,\n borrow,\n getDebtIn,\n permit\n}\n\n// ========================= Interfaces =============================\n\n/// @title IVaultManagerFunctions\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface only contains functions of the contract which are called by other contracts\n/// of this module (without getters)\ninterface IVaultManagerFunctions {\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\n /// @param repayData Data to pass to the repayment contract in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approved Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approved,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n\n/// @title IVaultManagerStorage\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface contains getters of the contract's public variables used by other contracts\n/// of this module\ninterface IVaultManagerStorage {\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\n function treasury() external view returns (ITreasury);\n\n /// @notice Reference to the collateral handled by this `VaultManager`\n function collateral() external view returns (IERC20);\n\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\n function vaultIDCount() external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) 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(\n IERC20 token,\n address spender,\n uint256 value\n ) 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 function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\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 if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\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 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.6.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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n" + }, + "contracts/interfaces/ITreasury.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ITreasury\n/// @author Angle Core Team\n/// @notice Interface for the `Treasury` contract\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\n/// of this module\ninterface ITreasury {\n /// @notice Checks whether a given address has well been initialized in this contract\n /// as a `VaultManager``\n /// @param _vaultManager Address to check\n /// @return Whether the address has been initialized or not\n function isVaultManager(address _vaultManager) external view returns (bool);\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-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(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 require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "contracts/mock/MockRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/external/IWETH9.sol\";\n\nimport \"../BaseAngleRouterSidechain.sol\";\n\n/// @title MockRouterSidechain\n/// @author Angle Core Team\n/// @notice Mock contract but built for tests as if to be deployed on Ethereum\ncontract MockRouterSidechain is BaseAngleRouterSidechain {\n IWETH9 public constant WETH = IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n function _wrapNative() internal pure override returns (uint256) {\n return 0;\n }\n\n function _unwrapNative(uint256, address) internal pure override returns (uint256 amount) {\n return 0;\n }\n\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return WETH;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\ninterface IERC20PermitUpgradeable {\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 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-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\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 value {ERC20} uses, unless this function is\n * 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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 IERC20Upgradeable {\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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\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-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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] = _HEX_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" + }, + "contracts/interfaces/IVeANGLE.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @title IVeANGLE\n/// @author Angle Core Team\n/// @notice Interface for the `VeANGLE` contract\ninterface IVeANGLE {\n // solhint-disable-next-line func-name-mixedcase\n function deposit_for(address addr, uint256 amount) external;\n}\n" + }, + "contracts/implementations/mainnet/AngleRouterMainnet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../interfaces/IFeeDistributorFront.sol\";\nimport \"../../interfaces/ISanToken.sol\";\nimport \"../../interfaces/IStableMasterFront.sol\";\nimport \"../../interfaces/IVeANGLE.sol\";\n\nimport \"../../BaseRouter.sol\";\n\n// ============================= STRUCTS AND ENUMS =============================\n\n/// @notice References to the contracts associated to a collateral for a stablecoin\nstruct Pairs {\n IPoolManager poolManager;\n IPerpetualManagerFrontWithClaim perpetualManager;\n ISanToken sanToken;\n ILiquidityGauge gauge;\n}\n\n/// @title AngleRouterMainnet\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Ethereum\n/// @dev Previous implementation with an initialization function can be found here:\n/// https://etherscan.io/address/0x1b2ffdad478d8770ea0e085bdd4e31120736fcd7#code\ncontract AngleRouterMainnet is BaseRouter {\n using SafeERC20 for IERC20;\n\n // =================================== ERRORS ==================================\n\n error InvalidParams();\n\n // ================================== MAPPINGS =================================\n\n /// @notice Maps an agToken to its counterpart `StableMaster`\n mapping(IERC20 => IStableMasterFront) public mapStableMasters;\n /// @notice Maps a `StableMaster` to a mapping of collateral token to its counterpart `PoolManager`\n mapping(IStableMasterFront => mapping(IERC20 => Pairs)) public mapPoolManagers;\n\n uint256[48] private __gapMainnet;\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.claimRewardsWithPerps) {\n (\n address user,\n address[] memory claimLiquidityGauges,\n uint256[] memory claimPerpetualIDs,\n bool addressProcessed,\n address[] memory stablecoins,\n address[] memory collateralsOrPerpetualManagers\n ) = abi.decode(data, (address, address[], uint256[], bool, address[], address[]));\n _claimRewardsWithPerps(\n user,\n claimLiquidityGauges,\n claimPerpetualIDs,\n addressProcessed,\n stablecoins,\n collateralsOrPerpetualManagers\n );\n } else if (action == ActionType.claimWeeklyInterest) {\n (address user, address feeDistributor, bool letInContract) = abi.decode(data, (address, address, bool));\n _claimWeeklyInterest(user, IFeeDistributorFront(feeDistributor), letInContract);\n } else if (action == ActionType.veANGLEDeposit) {\n (address user, uint256 amount) = abi.decode(data, (address, uint256));\n _depositOnLocker(user, amount);\n } else if (action == ActionType.deposit) {\n (\n address user,\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateral,\n address poolManager\n ) = abi.decode(data, (address, uint256, bool, address, address, address));\n _deposit(user, amount, addressProcessed, stablecoinOrStableMaster, collateral, IPoolManager(poolManager));\n } else if (action == ActionType.withdraw) {\n (\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateralOrPoolManager,\n address sanToken\n ) = abi.decode(data, (uint256, bool, address, address, address));\n if (amount == type(uint256).max) amount = IERC20(sanToken).balanceOf(address(this));\n _withdraw(amount, addressProcessed, stablecoinOrStableMaster, collateralOrPoolManager);\n }\n }\n\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n }\n\n /// @notice Claims rewards for multiple gauges and perpetuals at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @param perpetualIDs Perpetual IDs to claim rewards for\n /// @param addressProcessed Whether `PerpetualManager` list is already accessible in `collateralsOrPerpetualManagers` or if\n /// it should be retrieved from `stablecoins` and `collateralsOrPerpetualManagers`\n /// @param stablecoins Stablecoin contracts linked to the perpetualsIDs. Array of zero addresses if `addressProcessed` is true\n /// @param collateralsOrPerpetualManagers Collateral contracts linked to the perpetualsIDs or `perpetualManager` contracts if\n /// `addressProcessed` is true\n function _claimRewardsWithPerps(\n address gaugeUser,\n address[] memory liquidityGauges,\n uint256[] memory perpetualIDs,\n bool addressProcessed,\n address[] memory stablecoins,\n address[] memory collateralsOrPerpetualManagers\n ) internal {\n uint256 perpetualIDsLength = perpetualIDs.length;\n if (\n perpetualIDsLength != 0 &&\n (stablecoins.length != perpetualIDsLength || collateralsOrPerpetualManagers.length != perpetualIDsLength)\n ) revert IncompatibleLengths();\n\n uint256 liquidityGaugesLength = liquidityGauges.length;\n for (uint256 i; i < liquidityGaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n\n for (uint256 i; i < perpetualIDsLength; ++i) {\n IPerpetualManagerFrontWithClaim perpManager;\n if (addressProcessed) perpManager = IPerpetualManagerFrontWithClaim(collateralsOrPerpetualManagers[i]);\n else {\n (, Pairs memory pairs) = _getInternalContracts(\n IERC20(stablecoins[i]),\n IERC20(collateralsOrPerpetualManagers[i])\n );\n perpManager = pairs.perpetualManager;\n }\n perpManager.getReward(perpetualIDs[i]);\n }\n }\n\n /// @notice Deposits ANGLE on an existing locker\n /// @param user Address to deposit for\n /// @param amount Amount to deposit\n function _depositOnLocker(address user, uint256 amount) internal {\n _getVeANGLE().deposit_for(user, amount);\n }\n\n /// @notice Claims weekly interest distribution and if wanted transfers it to the contract for future use\n /// @param user Address to claim for\n /// @param _feeDistributor Address of the fee distributor to claim to\n /// @dev If `letInContract` (and hence if funds are transferred to the router), you should approve the `angleRouter` to\n /// transfer the token claimed from the `feeDistributor`\n function _claimWeeklyInterest(address user, IFeeDistributorFront _feeDistributor, bool letInContract) internal {\n uint256 amount = _feeDistributor.claim(user);\n if (letInContract) {\n // Fetching info from the `FeeDistributor` to process correctly the withdrawal\n IERC20 token = IERC20(_feeDistributor.token());\n token.safeTransferFrom(msg.sender, address(this), amount);\n }\n }\n\n /// @notice Deposits collateral in the Core Module of the protocol\n /// @param user Address where to send the resulting sanTokens, if this address is the router address then it means\n /// that the intention is to stake the sanTokens obtained in a subsequent `gaugeDeposit` action\n /// @param amount Amount of collateral to deposit\n /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones\n /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false)\n /// or directly the `StableMaster` contract if `addressProcessed`\n /// @param collateral Token to deposit: it can be null if `addressProcessed` is true but in the corresponding\n /// action, the `mixer` needs to get a correct address to compute the amount of tokens to use for the deposit\n /// @param poolManager PoolManager associated to the `collateral` (null if `addressProcessed` is not true)\n function _deposit(\n address user,\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateral,\n IPoolManager poolManager\n ) internal {\n IStableMasterFront stableMaster;\n if (addressProcessed) {\n stableMaster = IStableMasterFront(stablecoinOrStableMaster);\n } else {\n Pairs memory pairs;\n (stableMaster, pairs) = _getInternalContracts(IERC20(stablecoinOrStableMaster), IERC20(collateral));\n poolManager = pairs.poolManager;\n }\n stableMaster.deposit(amount, user, poolManager);\n }\n\n /// @notice Withdraws sanTokens from the protocol\n /// @param amount Amount of sanTokens to withdraw\n /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones\n /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false)\n /// or directly the `StableMaster` contract if `addressProcessed`\n /// @param collateralOrPoolManager Collateral to withdraw (if `addressProcessed` is false) or directly\n /// the `PoolManager` contract if `addressProcessed`\n function _withdraw(\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateralOrPoolManager\n ) internal {\n IStableMasterFront stableMaster;\n IPoolManager poolManager;\n if (addressProcessed) {\n stableMaster = IStableMasterFront(stablecoinOrStableMaster);\n poolManager = IPoolManager(collateralOrPoolManager);\n } else {\n Pairs memory pairs;\n (stableMaster, pairs) = _getInternalContracts(\n IERC20(stablecoinOrStableMaster),\n IERC20(collateralOrPoolManager)\n );\n poolManager = pairs.poolManager;\n }\n stableMaster.withdraw(amount, address(this), address(this), poolManager);\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Gets Angle contracts associated to a pair (stablecoin, collateral)\n /// @param stablecoin Token associated to a `StableMaster`\n /// @param collateral Collateral to mint/deposit/open perpetual or add collateral from\n /// @dev This function is used to check that the parameters passed by people calling some of the main\n /// router functions are correct\n function _getInternalContracts(\n IERC20 stablecoin,\n IERC20 collateral\n ) internal view returns (IStableMasterFront stableMaster, Pairs memory pairs) {\n stableMaster = mapStableMasters[stablecoin];\n pairs = mapPoolManagers[stableMaster][collateral];\n if (address(stableMaster) == address(0) || address(pairs.poolManager) == address(0)) revert ZeroAddress();\n return (stableMaster, pairs);\n }\n\n /// @notice Returns the veANGLE address\n function _getVeANGLE() internal view virtual returns (IVeANGLE) {\n return IVeANGLE(0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5);\n }\n}\n" + }, + "contracts/interfaces/IFeeDistributorFront.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IFeeDistributorFront\n/// @author Interface for public use of the `FeeDistributor` contract\n/// @dev This interface is used for user related function\ninterface IFeeDistributorFront {\n function token() external returns (address);\n\n function claim(address _addr) external returns (uint256);\n\n function claim(address[20] memory _addr) external returns (bool);\n}\n" + }, + "contracts/interfaces/ISanToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ISanToken is IERC20Upgradeable {}\n" + }, + "contracts/interfaces/IStableMasterFront.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./IPoolManager.sol\";\nimport \"./ISanToken.sol\";\nimport \"./IPerpetualManager.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n// Struct to handle all the parameters to manage the fees\n// related to a given collateral pool (associated to the stablecoin)\nstruct MintBurnData {\n // Values of the thresholds to compute the minting fees\n // depending on HA hedge (scaled by `BASE_PARAMS`)\n uint64[] xFeeMint;\n // Values of the fees at thresholds (scaled by `BASE_PARAMS`)\n uint64[] yFeeMint;\n // Values of the thresholds to compute the burning fees\n // depending on HA hedge (scaled by `BASE_PARAMS`)\n uint64[] xFeeBurn;\n // Values of the fees at thresholds (scaled by `BASE_PARAMS`)\n uint64[] yFeeBurn;\n // Max proportion of collateral from users that can be covered by HAs\n // It is exactly the same as the parameter of the same name in `PerpetualManager`, whenever one is updated\n // the other changes accordingly\n uint64 targetHAHedge;\n // Minting fees correction set by the `FeeManager` contract: they are going to be multiplied\n // to the value of the fees computed using the hedge curve\n // Scaled by `BASE_PARAMS`\n uint64 bonusMalusMint;\n // Burning fees correction set by the `FeeManager` contract: they are going to be multiplied\n // to the value of the fees computed using the hedge curve\n // Scaled by `BASE_PARAMS`\n uint64 bonusMalusBurn;\n // Parameter used to limit the number of stablecoins that can be issued using the concerned collateral\n uint256 capOnStableMinted;\n}\n\n// Struct to handle all the variables and parameters to handle SLPs in the protocol\n// including the fraction of interests they receive or the fees to be distributed to\n// them\nstruct SLPData {\n // Last timestamp at which the `sanRate` has been updated for SLPs\n uint256 lastBlockUpdated;\n // Fees accumulated from previous blocks and to be distributed to SLPs\n uint256 lockedInterests;\n // Max interests used to update the `sanRate` in a single block\n // Should be in collateral token base\n uint256 maxInterestsDistributed;\n // Amount of fees left aside for SLPs and that will be distributed\n // when the protocol is collateralized back again\n uint256 feesAside;\n // Part of the fees normally going to SLPs that is left aside\n // before the protocol is collateralized back again (depends on collateral ratio)\n // Updated by keepers and scaled by `BASE_PARAMS`\n uint64 slippageFee;\n // Portion of the fees from users minting and burning\n // that goes to SLPs (the rest goes to surplus)\n uint64 feesForSLPs;\n // Slippage factor that's applied to SLPs exiting (depends on collateral ratio)\n // If `slippage = BASE_PARAMS`, SLPs can get nothing, if `slippage = 0` they get their full claim\n // Updated by keepers and scaled by `BASE_PARAMS`\n uint64 slippage;\n // Portion of the interests from lending\n // that goes to SLPs (the rest goes to surplus)\n uint64 interestsForSLPs;\n}\n\n/// @title IStableMasterFront\n/// @author Angle Core Team\n/// @dev Front interface, meaning only user-facing functions\ninterface IStableMasterFront {\n function collateralMap(IPoolManager poolManager)\n external\n view\n returns (\n IERC20 token,\n ISanToken sanToken,\n IPerpetualManagerFrontWithClaim perpetualManager,\n address oracle,\n uint256 stocksUsers,\n uint256 sanRate,\n uint256 collatBase,\n SLPData memory slpData,\n MintBurnData memory feeData\n );\n\n function updateStocksUsers(uint256 amount, address poolManager) external;\n\n function mint(\n uint256 amount,\n address user,\n IPoolManager poolManager,\n uint256 minStableAmount\n ) external;\n\n function burn(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager,\n uint256 minCollatAmount\n ) external;\n\n function deposit(\n uint256 amount,\n address user,\n IPoolManager poolManager\n ) external;\n\n function withdraw(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager\n ) external;\n\n function agToken() external returns (address);\n}\n" + }, + "contracts/interfaces/IPoolManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface IPoolManager {\n function token() external view returns (address);\n}\n" + }, + "contracts/interfaces/IPerpetualManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title Interface of the contract managing perpetuals with claim function\n/// @author Angle Core Team\n/// @dev Front interface with rewards function, meaning only user-facing functions\ninterface IPerpetualManagerFrontWithClaim {\n function getReward(uint256 perpetualID) external;\n\n function addToPerpetual(uint256 perpetualID, uint256 amount) external;\n\n function openPerpetual(\n address owner,\n uint256 amountBrought,\n uint256 amountCommitted,\n uint256 maxOracleRate,\n uint256 minNetMargin\n ) external returns (uint256 perpetualID);\n}\n" + }, + "contracts/mock/MockAngleRouterMainnet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../implementations/mainnet/AngleRouterMainnet.sol\";\n\ncontract MockAngleRouterMainnet is AngleRouterMainnet {\n address public veAngle;\n\n function setAngleAndVeANGLE(address _veAngle) external {\n veAngle = _veAngle;\n }\n\n function _getVeANGLE() internal view override returns (IVeANGLE) {\n return IVeANGLE(veAngle);\n }\n\n function addStableMaster(IERC20 stablecoin, IStableMasterFront stableMaster) external {\n mapStableMasters[stablecoin] = stableMaster;\n }\n\n function addPairs(\n IERC20[] calldata stablecoins,\n IPoolManager[] calldata poolManagers,\n ILiquidityGauge[] calldata liquidityGauges,\n bool[] calldata justLiquidityGauges\n ) external {\n for (uint256 i; i < stablecoins.length; ++i) {\n IStableMasterFront stableMaster = mapStableMasters[stablecoins[i]];\n _addPair(stableMaster, poolManagers[i], liquidityGauges[i], justLiquidityGauges[i]);\n }\n }\n\n function _addPair(\n IStableMasterFront stableMaster,\n IPoolManager poolManager,\n ILiquidityGauge liquidityGauge,\n bool justLiquidityGauge\n ) internal {\n // Fetching the associated `sanToken` and `perpetualManager` from the contract\n (\n IERC20 collateral,\n ISanToken sanToken,\n IPerpetualManagerFrontWithClaim perpetualManager,\n ,\n ,\n ,\n ,\n ,\n\n ) = stableMaster.collateralMap(poolManager);\n // Reverting if the poolManager is not a valid `poolManager`\n if (address(collateral) == address(0)) revert InvalidParams();\n Pairs storage _pairs = mapPoolManagers[stableMaster][collateral];\n if (justLiquidityGauge) {\n // Cannot specify a liquidity gauge if the associated poolManager does not exist\n if (address(_pairs.poolManager) == address(0)) revert ZeroAddress();\n ILiquidityGauge gauge = _pairs.gauge;\n if (address(gauge) != address(0)) {\n _changeAllowance(IERC20(address(sanToken)), address(gauge), 0);\n }\n } else {\n // Checking if the pair has not already been initialized: if yes we need to make the function revert\n // otherwise we could end up with still approved `PoolManager` and `PerpetualManager` contracts\n if (address(_pairs.poolManager) != address(0)) revert InvalidParams();\n _pairs.poolManager = poolManager;\n _pairs.perpetualManager = IPerpetualManagerFrontWithClaim(address(perpetualManager));\n _pairs.sanToken = sanToken;\n _changeAllowance(collateral, address(stableMaster), type(uint256).max);\n _changeAllowance(collateral, address(perpetualManager), type(uint256).max);\n }\n _pairs.gauge = liquidityGauge;\n if (address(liquidityGauge) != address(0)) {\n if (address(sanToken) != liquidityGauge.staking_token()) revert InvalidParams();\n _changeAllowance(IERC20(address(sanToken)), address(liquidityGauge), type(uint256).max);\n }\n }\n}\n\ncontract MockAngleRouterMainnet2 is AngleRouterMainnet {\n function getVeANGLE() external view returns (IVeANGLE) {\n return _getVeANGLE();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 value {ERC20} uses, unless this function is\n * 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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] = _HEX_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" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../utils/SafeERC20.sol\";\nimport \"../../../interfaces/IERC4626.sol\";\nimport \"../../../utils/math/Math.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of\n * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626 is ERC20, IERC4626 {\n using Math for uint256;\n\n IERC20Metadata private immutable _asset;\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n constructor(IERC20Metadata asset_) {\n _asset = asset_;\n }\n\n /** @dev See {IERC4262-asset}. */\n function asset() public view virtual override returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4262-totalAssets}. */\n function totalAssets() public view virtual override returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4262-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {\n return _convertToShares(assets, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {\n return _convertToAssets(shares, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-maxDeposit}. */\n function maxDeposit(address) public view virtual override returns (uint256) {\n return _isVaultCollateralized() ? type(uint256).max : 0;\n }\n\n /** @dev See {IERC4262-maxMint}. */\n function maxMint(address) public view virtual override returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4262-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual override returns (uint256) {\n return _convertToAssets(balanceOf(owner), Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-maxRedeem}. */\n function maxRedeem(address owner) public view virtual override returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4262-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-previewMint}. */\n function previewMint(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Up);\n }\n\n /** @dev See {IERC4262-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Up);\n }\n\n /** @dev See {IERC4262-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4262-mint}. */\n function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4262-withdraw}. */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4262-redeem}. */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n *\n * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset\n * would represent an infinite amout of shares.\n */\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256 shares) {\n uint256 supply = totalSupply();\n return\n (assets == 0 || supply == 0)\n ? assets.mulDiv(10**decimals(), 10**_asset.decimals(), rounding)\n : assets.mulDiv(supply, totalAssets(), rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256 assets) {\n uint256 supply = totalSupply();\n return\n (supply == 0)\n ? shares.mulDiv(10**_asset.decimals(), 10**decimals(), rounding)\n : shares.mulDiv(totalAssets(), supply, rounding);\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transfered and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transfered, which is a valid state.\n _burn(owner, shares);\n SafeERC20.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _isVaultCollateralized() private view returns (bool) {\n return totalAssets() > 0 || totalSupply() == 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) 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 return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\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(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) 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. It 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 // 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)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\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 uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "contracts/external/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin\n * `TransparentUpgradeableProxy`\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "contracts/external/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n * This contract was fully forked from OpenZeppelin `ProxyAdmin`\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{ value: msg.value }(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "contracts/mock/MockVeANGLE.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract MockVeANGLE {\n using SafeERC20 for IERC20;\n IERC20 public angle;\n mapping(address => uint256) public counter;\n\n //solhint-disable-next-line\n function deposit_for(address user, uint256 amount) external {\n angle.safeTransferFrom(msg.sender, address(this), amount);\n counter[user] = amount;\n }\n\n function setAngle(address _angle) external {\n angle = IERC20(_angle);\n }\n}\n" + }, + "contracts/mock/MockVaultManagerPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\nimport \"../interfaces/external/IERC1271.sol\";\n\ncontract MockVaultManagerPermit {\n using Address for address;\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n uint256 public vaultIDCount;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private _PERMIT_TYPEHASH;\n /* solhint-enable var-name-mixedcase */\n\n PaymentData public paymentData;\n\n mapping(address => uint256) private _nonces;\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => uint256)) public operatorApprovals;\n mapping(uint256 => mapping(address => bool)) public approved;\n error ExpiredDeadline();\n error InvalidSignature();\n\n constructor(string memory _name) {\n _PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,bool approved,uint256 nonce,uint256 deadline)\"\n );\n _HASHED_NAME = keccak256(bytes(_name));\n _HASHED_VERSION = keccak256(bytes(\"1\"));\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function updateVaultIDCount(uint256 _vaultIDCount) external {\n vaultIDCount = _vaultIDCount;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable virtual returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n if (paymentData.stablecoinAmountToReceive >= paymentData.stablecoinAmountToGive) {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToReceive - paymentData.stablecoinAmountToGive;\n if (paymentData.collateralAmountToGive >= paymentData.collateralAmountToReceive) {\n uint256 collateralAmountToGive = paymentData.collateralAmountToGive -\n paymentData.collateralAmountToReceive;\n collateral.safeTransfer(to, collateralAmountToGive);\n stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n } else {\n if (stablecoinPayment > 0) stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n // In this case the collateral amount is necessarily non null\n collateral.safeTransferFrom(\n msg.sender,\n address(this),\n paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive\n );\n }\n } else {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToGive - paymentData.stablecoinAmountToReceive;\n // `stablecoinPayment` is strictly positive in this case\n stablecoin.mint(to, stablecoinPayment);\n if (paymentData.collateralAmountToGive > paymentData.collateralAmountToReceive) {\n collateral.safeTransfer(to, paymentData.collateralAmountToGive - paymentData.collateralAmountToReceive);\n } else {\n uint256 collateralPayment = paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive;\n collateral.safeTransferFrom(msg.sender, address(this), collateralPayment);\n }\n }\n\n return paymentData;\n }\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approvedStatus Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approvedStatus,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n if (block.timestamp > deadline) revert ExpiredDeadline();\n // Additional signature checks performed in the `ECDSAUpgradeable.recover` function\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 || (v != 27 && v != 28))\n revert InvalidSignature();\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n _domainSeparatorV4(),\n keccak256(\n abi.encode(\n _PERMIT_TYPEHASH,\n // 0x3f43a9c6bafb5c7aab4e0cfe239dc5d4c15caf0381c6104188191f78a6640bd8,\n owner,\n spender,\n approvedStatus,\n _useNonce(owner),\n deadline\n )\n )\n )\n );\n if (owner.isContract()) {\n if (IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) != 0x1626ba7e)\n revert InvalidSignature();\n } else {\n address signer = ecrecover(digest, v, r, s);\n if (signer != owner || signer == address(0)) revert InvalidSignature();\n }\n\n _setApprovalForAll(owner, spender, approvedStatus);\n }\n\n function approveSpenderVault(\n address spender,\n uint256 vaultID,\n bool status\n ) external {\n approved[vaultID][spender] = status;\n }\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool) {\n return approved[vaultID][spender];\n }\n\n /// @notice Internal version of the `setApprovalForAll` function\n /// @dev It contains an `approver` field to be used in case someone signs a permit for a particular\n /// address, and this signature is given to the contract by another address (like a router)\n function _setApprovalForAll(\n address approver,\n address operator,\n bool approvedStatus\n ) internal {\n if (operator == approver) revert(\"approval to caller\");\n uint256 approval = approvedStatus ? 1 : 0;\n operatorApprovals[approver][operator] = approval;\n }\n\n /// @notice Returns the current nonce for an `owner` address\n function nonces(address owner) public view returns (uint256) {\n return _nonces[owner];\n }\n\n /// @notice Returns the domain separator for the current chain.\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /// @notice Internal version of the `DOMAIN_SEPARATOR` function\n function _domainSeparatorV4() internal view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n // keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')\n 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,\n _HASHED_NAME,\n _HASHED_VERSION,\n block.chainid,\n address(this)\n )\n );\n }\n\n /// @notice Consumes a nonce for an address: returns the current value and increments it\n function _useNonce(address owner) internal returns (uint256 current) {\n current = _nonces[owner];\n _nonces[owner] = current + 1;\n }\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/interfaces/IAgToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @title IAgToken\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts\n/// @dev The only functions that are left in the interface are the functions which are used\n/// at another point in the protocol by a different contract\ninterface IAgToken is IERC20Upgradeable {\n // ======================= `StableMaster` functions ============================\n function mint(address account, uint256 amount) external;\n\n function burnFrom(\n uint256 amount,\n address burner,\n address sender\n ) external;\n\n function burnSelf(uint256 amount, address burner) external;\n\n // ========================= External function =================================\n\n function stableMaster() external view returns (address);\n}\n" + }, + "contracts/interfaces/external/IERC1271.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\n/// @title Interface for verifying contract-based account signatures\n/// @notice Interface that verifies provided signature for the data\n/// @dev Interface defined by EIP-1271\ninterface IERC1271 {\n /// @notice Returns whether the provided signature is valid for the provided data\n /// @dev MUST return the bytes4 magic value 0x1626ba7e when function passes.\n /// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5).\n /// MUST allow external calls.\n /// @param hash Hash of the data to be signed\n /// @param signature Signature byte array associated with _data\n /// @return magicValue The bytes4 magic value 0x1626ba7e\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n" + }, + "contracts/mock/MockVaultManagerPermitCollateral.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./MockVaultManagerPermit.sol\";\n\ncontract MockVaultManagerPermitCollateral is MockVaultManagerPermit {\n using Address for address;\n using SafeERC20 for IERC20;\n\n mapping(uint256 => uint256) public collatData;\n\n constructor(string memory _name) MockVaultManagerPermit(_name) {}\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address,\n address,\n address,\n bytes memory\n ) public payable override returns (PaymentData memory) {\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n if (action == ActionBorrowType.addCollateral) {\n (uint256 vaultID, uint256 collateralAmount) = abi.decode(datas[i], (uint256, uint256));\n collatData[vaultID] += collateralAmount;\n collateral.safeTransferFrom(msg.sender, address(this), collateralAmount);\n }\n }\n PaymentData memory returnValue;\n return returnValue;\n }\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/mock/MockVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\n\ncontract MockVaultManager {\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n PaymentData public paymentData;\n\n constructor(address _treasury) {\n treasury = ITreasury(_treasury);\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n if (paymentData.stablecoinAmountToReceive >= paymentData.stablecoinAmountToGive) {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToReceive - paymentData.stablecoinAmountToGive;\n if (paymentData.collateralAmountToGive >= paymentData.collateralAmountToReceive) {\n uint256 collateralAmountToGive = paymentData.collateralAmountToGive -\n paymentData.collateralAmountToReceive;\n collateral.safeTransfer(to, collateralAmountToGive);\n stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n } else {\n if (stablecoinPayment > 0) stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n // In this case the collateral amount is necessarily non null\n collateral.safeTransferFrom(\n msg.sender,\n address(this),\n paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive\n );\n }\n } else {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToGive - paymentData.stablecoinAmountToReceive;\n // `stablecoinPayment` is strictly positive in this case\n stablecoin.mint(to, stablecoinPayment);\n if (paymentData.collateralAmountToGive > paymentData.collateralAmountToReceive) {\n collateral.safeTransfer(to, paymentData.collateralAmountToGive - paymentData.collateralAmountToReceive);\n } else {\n uint256 collateralPayment = paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive;\n collateral.safeTransferFrom(msg.sender, address(this), collateralPayment);\n }\n }\n\n return paymentData;\n }\n}\n" + }, + "contracts/mock/MockFraudVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\n\ncontract MockFraudVaultManager {\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n PaymentData public paymentData;\n\n constructor(address _treasury) {\n treasury = ITreasury(_treasury);\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n return paymentData;\n }\n}\n" + }, + "contracts/mock/MockAgToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../interfaces/IAgToken.sol\";\nimport \"../interfaces/IStableMasterFront.sol\";\nimport \"../interfaces/ITreasury.sol\";\n// OpenZeppelin may update its version of the ERC20PermitUpgradeable token\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title AgToken\n/// @author Angle Core Team\n/// @notice Base contract for agToken, that is to say Angle's stablecoins\n/// @dev This contract is used to create and handle the stablecoins of Angle protocol\n/// @dev It is still possible for any address to burn its agTokens without redeeming collateral in exchange\n/// @dev This contract is the upgraded version of the AgToken that was first deployed on Ethereum mainnet\ncontract MockAgToken is IAgToken, ERC20PermitUpgradeable {\n using SafeERC20 for IERC20;\n // ========================= References to other contracts =====================\n\n /// @notice Reference to the `StableMaster` contract associated to this `AgToken`\n address public override stableMaster;\n uint256 public inFees;\n uint256 public outFees;\n uint256 public constant BASE_PARAMS = 10**9;\n\n // ============================= Constructor ===================================\n\n /// @notice Initializes the `AgToken` contract\n /// @param name_ Name of the token\n /// @param symbol_ Symbol of the token\n /// @param stableMaster_ Reference to the `StableMaster` contract associated to this agToken\n /// @dev By default, agTokens are ERC-20 tokens with 18 decimals\n function initialize(\n string memory name_,\n string memory symbol_,\n address stableMaster_,\n ITreasury _treasury\n ) external initializer {\n __ERC20Permit_init(name_);\n __ERC20_init(name_, symbol_);\n stableMaster = stableMaster_;\n treasury = _treasury;\n isMinter[stableMaster] = true;\n }\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() initializer {}\n\n // ======= Added Parameters and Variables from the first implementation ========\n\n mapping(address => bool) public isMinter;\n /// @notice Reference to the treasury contract which can grant minting rights\n ITreasury public treasury;\n\n // =============================== Added Events ================================\n\n event TreasuryUpdated(address indexed _treasury);\n event MinterToggled(address indexed minter);\n\n // =============================== Modifiers ===================================\n\n /// @notice Checks to see if it is the `StableMaster` calling this contract\n /// @dev There is no Access Control here, because it can be handled cheaply through this modifier\n modifier onlyTreasury() {\n require(msg.sender == address(treasury), \"1\");\n _;\n }\n\n /// @notice Checks whether the sender has the minting right\n modifier onlyMinter() {\n require(isMinter[msg.sender], \"35\");\n _;\n }\n\n // ========================= External Functions ================================\n // The following functions allow anyone to burn stablecoins without redeeming collateral\n // in exchange for that\n\n /// @notice Destroys `amount` token from the caller without giving collateral back\n /// @param amount Amount to burn\n /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will\n /// need to be updated\n /// @dev When calling this function, people should specify the `poolManager` for which they want to decrease\n /// the `stocksUsers`: this a way for the protocol to maintain healthy accounting variables\n function burnNoRedeem(uint256 amount, address poolManager) external {\n _burn(msg.sender, amount);\n IStableMasterFront(stableMaster).updateStocksUsers(amount, poolManager);\n }\n\n /// @notice Burns `amount` of agToken on behalf of another account without redeeming collateral back\n /// @param account Account to burn on behalf of\n /// @param amount Amount to burn\n /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will need to be updated\n function burnFromNoRedeem(\n address account,\n uint256 amount,\n address poolManager\n ) external {\n _burnFromNoRedeem(amount, account, msg.sender);\n IStableMasterFront(stableMaster).updateStocksUsers(amount, poolManager);\n }\n\n /// @notice Allows anyone to burn agToken without redeeming collateral back\n /// @param amount Amount of stablecoins to burn\n /// @dev This function can typically be called if there is a settlement mechanism to burn stablecoins\n function burnStablecoin(uint256 amount) external {\n _burn(msg.sender, amount);\n }\n\n // ======================= Minter Role Only Functions ==========================\n\n /// @inheritdoc IAgToken\n function burnSelf(uint256 amount, address burner) external override {\n _burn(burner, amount);\n }\n\n /// @inheritdoc IAgToken\n function burnFrom(\n uint256 amount,\n address burner,\n address sender\n ) external override onlyMinter {\n _burnFromNoRedeem(amount, burner, sender);\n }\n\n /// @inheritdoc IAgToken\n function mint(address account, uint256 amount) external override {\n _mint(account, amount);\n }\n\n // ======================= Treasury Only Functions =============================\n\n function addMinter(address minter) external {\n isMinter[minter] = true;\n emit MinterToggled(minter);\n }\n\n function removeMinter(address minter) external {\n // The `treasury` contract cannot remove the `stableMaster`\n require((msg.sender == address(treasury) && minter != stableMaster) || msg.sender == minter, \"36\");\n isMinter[minter] = false;\n emit MinterToggled(minter);\n }\n\n function setTreasury(address _treasury) external onlyTreasury {\n treasury = ITreasury(_treasury);\n emit TreasuryUpdated(_treasury);\n }\n\n // ============================ Internal Function ==============================\n\n /// @notice Internal version of the function `burnFromNoRedeem`\n /// @param amount Amount to burn\n /// @dev It is at the level of this function that allowance checks are performed\n function _burnFromNoRedeem(\n uint256 amount,\n address burner,\n address sender\n ) internal {\n if (burner != sender) {\n uint256 currentAllowance = allowance(burner, sender);\n require(currentAllowance >= amount, \"23\");\n _approve(burner, sender, currentAllowance - amount);\n }\n _burn(burner, amount);\n }\n\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256) {\n IERC20(bridgeToken).safeTransferFrom(msg.sender, address(this), amount);\n uint256 canonicalOut = (amount * (BASE_PARAMS - inFees)) / BASE_PARAMS;\n _mint(to, canonicalOut);\n return canonicalOut;\n }\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256) {\n _burn(msg.sender, amount);\n uint256 bridgeOut = (amount * (BASE_PARAMS - outFees)) / BASE_PARAMS;\n\n IERC20(bridgeToken).safeTransfer(to, bridgeOut);\n return bridgeOut;\n }\n\n function setFees(uint256 _inFees, uint256 _outFees) external {\n inFees = _inFees;\n outFees = _outFees;\n }\n}\n" + }, + "contracts/mock/MockStableMaster.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\nimport \"../interfaces/ISanToken.sol\";\nimport \"../interfaces/IPerpetualManager.sol\";\nimport \"../interfaces/IStableMasterFront.sol\";\n\nimport \"./MockAgToken.sol\";\n\ncontract MockStableMaster is IStableMasterFront {\n using SafeERC20 for IERC20;\n address public agToken;\n\n constructor(address _agToken) {\n agToken = _agToken;\n }\n\n struct Collateral {\n IERC20 collateral;\n ISanToken sanToken;\n IPerpetualManagerFrontWithClaim perpetualManager;\n address oracle;\n uint256 stocksUsers;\n uint256 sanRate;\n uint256 collatBase;\n SLPData slpData;\n MintBurnData feeData;\n }\n\n mapping(IPoolManager => Collateral) public collateralMap;\n\n function addCollateral(\n address poolManager,\n address collateral,\n address sanToken,\n address perpetualManager\n ) external {\n Collateral memory collat;\n collat.collateral = IERC20(collateral);\n collat.sanToken = ISanToken(sanToken);\n collat.perpetualManager = IPerpetualManagerFrontWithClaim(perpetualManager);\n collateralMap[IPoolManager(poolManager)] = collat;\n }\n\n function mint(\n uint256 amount,\n address user,\n IPoolManager poolManager,\n uint256\n ) external {\n collateralMap[poolManager].collateral.safeTransferFrom(msg.sender, address(this), amount);\n MockAgToken(agToken).mint(user, amount);\n }\n\n function burn(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager,\n uint256\n ) external {\n MockAgToken(agToken).burnSelf(amount, burner);\n collateralMap[poolManager].collateral.safeTransfer(dest, amount);\n }\n\n function deposit(\n uint256 amount,\n address user,\n IPoolManager poolManager\n ) external {\n collateralMap[poolManager].collateral.safeTransferFrom(msg.sender, address(this), amount);\n IERC20(address(collateralMap[poolManager].sanToken)).safeTransfer(user, amount);\n }\n\n function withdraw(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager\n ) external {\n IERC20(address(collateralMap[poolManager].sanToken)).safeTransferFrom(burner, address(this), amount);\n collateralMap[poolManager].collateral.safeTransfer(dest, amount);\n }\n\n function updateStocksUsers(uint256, address) external {}\n}\n" + }, + "contracts/mock/MockPerpetualManager.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/ISanToken.sol\";\nimport \"../interfaces/IPerpetualManager.sol\";\n\ncontract MockPerpetualManager {\n using SafeERC20 for IERC20;\n\n IERC20 public rewardToken;\n IERC20 public token;\n uint256 public counter;\n mapping(uint256 => uint256) public perps;\n mapping(uint256 => uint256) public claims;\n\n function setRewardToken(address _rewardToken) external {\n rewardToken = IERC20(_rewardToken);\n }\n\n function setToken(address _token) external {\n token = IERC20(_token);\n }\n\n function getReward(uint256 perpetualID) external {\n claims[perpetualID] += 1;\n }\n\n function addToPerpetual(uint256 perpetualID, uint256 amount) external {\n token.safeTransferFrom(msg.sender, address(this), amount);\n perps[perpetualID] += amount;\n }\n\n function openPerpetual(\n address,\n uint256 amountBrought,\n uint256,\n uint256,\n uint256\n ) external returns (uint256 perpetualID) {\n token.safeTransferFrom(msg.sender, address(this), amountBrought);\n perpetualID = counter;\n counter += 1;\n perps[perpetualID] = amountBrought;\n }\n}\n" + }, + "contracts/mock/MockSwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract MockSwapper {\n using SafeERC20 for IERC20;\n\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory\n ) external {\n inToken.safeTransferFrom(msg.sender, address(this), inTokenObtained);\n outToken.safeTransfer(outTokenRecipient, outTokenOwed);\n }\n}\n" + }, + "contracts/mock/MockLiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../interfaces/ILiquidityGauge.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @notice MockLiquidityGauge contract\ncontract MockLiquidityGauge is ILiquidityGauge {\n using SafeERC20 for IERC20;\n\n uint256 public factor = 10**18;\n\n IERC20 public token;\n mapping(address => uint256) public counter;\n mapping(address => uint256) public counter2;\n\n constructor(address _token) {\n token = IERC20(_token);\n }\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external override {\n IERC20(_rewardToken).transferFrom(msg.sender, address(this), _amount);\n }\n\n function setFactor(uint256 _factor) external {\n factor = _factor;\n }\n\n // solhint-disable-next-line\n function staking_token() external view override returns (address stakingToken) {\n return address(token);\n }\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external override {\n _value;\n _addr;\n _claim_rewards;\n counter2[_addr] += 1;\n return;\n }\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external override {\n _addr;\n counter[_addr] += 1;\n return;\n }\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external pure override {\n _addr;\n _receiver;\n return;\n }\n}\n" + }, + "contracts/mock/MockFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ncontract MockFeeDistributor {\n using SafeERC20 for IERC20;\n\n address public token;\n\n constructor() {}\n\n function claim(address user) external returns (uint256 amount) {\n amount = IERC20(token).balanceOf(address(this));\n IERC20(token).safeTransfer(user, amount);\n }\n\n function setToken(address _token) external {\n token = _token;\n }\n}\n" + }, + "contracts/interfaces/external/lido/IWStETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title IWStETH\n/// @author Angle Core Team\n/// @notice Interface for the `WStETH` contract\n/// @dev This interface only contains functions of the `WStETH` which are called by other contracts\n/// of this module\ninterface IWStETH is IERC20 {\n function stETH() external returns (address);\n\n function wrap(uint256 _stETHAmount) external returns (uint256);\n\n function unwrap(uint256 _wstETHAmount) external returns (uint256);\n}\n" + }, + "contracts/interfaces/external/lido/ISteth.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IStETH is IERC20 {\n event Submitted(address sender, uint256 amount, address referral);\n\n function submit(address) external payable returns (uint256);\n\n function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256);\n}\n" + }, + "contracts/mock/MockUniswapV3Router.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"../interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./MockTokenPermit.sol\";\n\n// @notice mock contract to swap token\ncontract MockUniswapV3Router is IUniswapV3Router {\n uint256 public exchangeRate = 1 ether;\n IERC20Metadata public tokenA;\n IERC20Metadata public tokenB;\n uint256 public decimalsA;\n uint256 public decimalsB;\n\n constructor(IERC20Metadata _tokenA, IERC20Metadata _tokenB) {\n tokenA = _tokenA;\n tokenB = _tokenB;\n decimalsA = _tokenA.decimals();\n decimalsB = _tokenB.decimals();\n MockTokenPermit(address(tokenB)).mint(address(this), type(uint256).max / 1000);\n }\n\n function exactInput(ExactInputParams calldata params) external payable override returns (uint256 amountOut) {\n tokenA.transferFrom(msg.sender, address(this), params.amountIn);\n amountOut = (((params.amountIn * exchangeRate) / 1 ether) * 10**decimalsB) / 10**decimalsA;\n tokenB.transfer(msg.sender, amountOut);\n }\n\n function updateExchangeRate(uint256 newExchangeRate) external {\n exchangeRate = newExchangeRate;\n }\n}\n" + }, + "contracts/mock/MockTokenPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\ncontract MockTokenPermit is ERC20Permit {\n event Minting(address indexed _to, address indexed _minter, uint256 _amount);\n\n event Burning(address indexed _from, address indexed _burner, uint256 _amount);\n\n uint8 internal _decimal;\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) ERC20Permit(name_) ERC20(name_, symbol_) {\n _decimal = decimal_;\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 function decimals() public view override returns (uint8) {\n return _decimal;\n }\n\n /// @notice allow to mint\n /// @param account the account to mint to\n /// @param amount the amount to mint\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n emit Minting(account, msg.sender, amount);\n }\n\n /// @notice allow to burn\n /// @param account the account to burn from\n /// @param amount the amount of agToken to burn from caller\n function burn(address account, uint256 amount) public {\n _burn(account, amount);\n emit Burning(account, msg.sender, amount);\n }\n\n function setAllowance(address from, address to) public {\n _approve(from, to, type(uint256).max);\n }\n}\n" + }, + "contracts/mock/Mock1Inch.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./MockTokenPermit.sol\";\n\nstruct SwapDescription {\n IERC20 srcToken;\n IERC20 dstToken;\n address payable srcReceiver;\n address payable dstReceiver;\n uint256 amount;\n uint256 minReturnAmount;\n uint256 flags;\n bytes permit;\n}\n\n// File contracts/interfaces/IAggregationExecutor.sol\n/// @title Interface for making arbitrary calls during swap\ninterface IAggregationExecutor {\n /// @notice Make calls on `msgSender` with specified data\n function callBytes(address msgSender, bytes calldata data) external payable; // 0x2636f7f8\n}\n\n// @notice mock contract to swap token\ncontract Mock1Inch {\n uint256 public exchangeRate = 1 ether;\n IERC20Metadata public tokenA;\n IERC20Metadata public tokenB;\n uint256 public decimalsA;\n uint256 public decimalsB;\n\n constructor(IERC20Metadata _tokenA, IERC20Metadata _tokenB) {\n tokenA = _tokenA;\n tokenB = _tokenB;\n decimalsA = _tokenA.decimals();\n decimalsB = _tokenB.decimals();\n MockTokenPermit(address(tokenB)).mint(address(this), type(uint256).max / 1000);\n }\n\n function swap(\n IAggregationExecutor caller,\n SwapDescription calldata desc,\n bytes calldata data\n )\n external\n payable\n returns (\n uint256 returnAmount,\n uint256 spentAmount,\n uint256 gasLeft\n )\n {\n caller;\n data;\n spentAmount;\n gasLeft;\n tokenA.transferFrom(msg.sender, address(this), desc.amount);\n returnAmount = (((desc.amount * exchangeRate) / 1 ether) * 10**decimalsB) / 10**decimalsA;\n tokenB.transfer(msg.sender, returnAmount);\n }\n\n function unsupportedSwap() external payable returns (address returnAmount) {\n return address(this);\n }\n\n function revertingSwap() external payable {\n revert(\"wrong swap\");\n }\n\n function updateExchangeRate(uint256 newExchangeRate) external {\n exchangeRate = newExchangeRate;\n }\n}\n" + }, + "contracts/mock/MockSavingsRate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\n\ncontract MockSavingsRate is ERC4626 {\n constructor(IERC20Metadata asset_) ERC20(\"savingsRate\", \"sr\") ERC4626(asset_) {}\n}\n" + }, + "contracts/mock/MockERC4626.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\n\ncontract MockERC4626 is ERC4626 {\n constructor(\n IERC20Metadata asset_,\n string memory name_,\n string memory symbol_\n ) ERC4626(asset_) ERC20(name_, symbol_) {}\n}\n" + }, + "contracts/mock/MockToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MockToken is ERC20 {\n event Minting(address indexed _to, address indexed _minter, uint256 _amount);\n\n event Burning(address indexed _from, address indexed _burner, uint256 _amount);\n\n uint8 internal _decimal;\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) ERC20(name_, symbol_) {\n _decimal = decimal_;\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 function decimals() public view override returns (uint8) {\n return _decimal;\n }\n\n /// @notice allow to mint\n /// @param account the account to mint to\n /// @param amount the amount to mint\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n emit Minting(account, msg.sender, amount);\n }\n\n /// @notice allow to burn\n /// @param account the account to burn from\n /// @param amount the amount of agToken to burn from caller\n function burn(address account, uint256 amount) public {\n _burn(account, amount);\n emit Burning(account, msg.sender, amount);\n }\n\n function setAllowance(address from, address to) public {\n _approve(from, to, type(uint256).max);\n }\n}\n" + }, + "contracts/mock/MockWETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./MockToken.sol\";\n\ncontract MockWETH is MockToken {\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n receive() external payable {}\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) MockToken(name_, symbol_, decimal_) {}\n\n function deposit() public payable {\n _mint(msg.sender, msg.value);\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n _burn(msg.sender, wad);\n (bool sent, ) = msg.sender.call{ value: wad }(\"\");\n require(sent, \"Failed to send Ether\");\n emit Withdrawal(msg.sender, wad);\n }\n}\n" + }, + "contracts/implementations/polygon/AngleRouterPolygon.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterPolygon\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Polygon\ncontract AngleRouterPolygon is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);\n }\n}\n" + }, + "contracts/implementations/optimism/AngleRouterOptimism.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterOptimism\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Optimism\ncontract AngleRouterOptimism is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x4200000000000000000000000000000000000006);\n }\n}\n" + }, + "contracts/implementations/avalanche/AngleRouterAvalanche.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterAvalanche\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Avalanche\ncontract AngleRouterAvalanche is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7);\n }\n}\n" + }, + "contracts/implementations/arbitrum/AngleRouterArbitrum.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterArbitrum\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Arbitrum\ncontract AngleRouterArbitrum is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1);\n }\n}\n" + }, + "contracts/mock/MockBorrowStaker.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ncontract MockBorrowStaker {\n mapping(address => uint256) public counter;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external returns (uint256[] memory) {\n _addr;\n counter[_addr] += 1;\n uint256[] memory returnValue = new uint256[](2);\n returnValue[0] = 1;\n returnValue[1] = 2;\n return returnValue;\n }\n}\n" + }, + "contracts/mock/MockCoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ncontract MockCoreBorrow {\n mapping(address => bool) public governors;\n mapping(address => bool) public guardians;\n\n function isGovernor(address admin) external view returns (bool) {\n return governors[admin];\n }\n\n function isGovernorOrGuardian(address admin) external view returns (bool) {\n return guardians[admin];\n }\n\n function toggleGovernor(address admin) external {\n governors[admin] = !governors[admin];\n }\n\n function toggleGuardian(address admin) external {\n guardians[admin] = !guardians[admin];\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "devdoc", + "userdoc" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/base/solcInputs/70c4b5d324ac01a99c0faeb5728c1fc2.json b/deployments/base/solcInputs/70c4b5d324ac01a99c0faeb5728c1fc2.json new file mode 100644 index 0000000..e0580bb --- /dev/null +++ b/deployments/base/solcInputs/70c4b5d324ac01a99c0faeb5728c1fc2.json @@ -0,0 +1,94 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "@openzeppelin/contracts/interfaces/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\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 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/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/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) 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(\n IERC20 token,\n address spender,\n uint256 value\n ) 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 function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\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 if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(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 require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "contracts/BaseAngleRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./interfaces/IAgTokenMultiChain.sol\";\nimport \"./BaseRouter.sol\";\n\n/// @title BaseAngleRouterSidechain\n/// @author Angle Core Team\n/// @notice Extension of the `BaseRouter` contract for sidechains\nabstract contract BaseAngleRouterSidechain is BaseRouter {\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\n /// gauges at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @dev If the caller wants to send the rewards to another account it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\n _claimRewards(gaugeUser, liquidityGauges);\n }\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.swapIn) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\n } else if (action == ActionType.swapOut) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\n }\n }\n\n /// @notice Wraps a bridge token to its corresponding canonical version\n function _swapIn(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n\n /// @notice Unwraps a canonical token for one of its bridge version\n function _swapOut(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n}\n" + }, + "contracts/BaseRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n * █ \n ***** ▓▓▓ \n * ▓▓▓▓▓▓▓ \n * ///. ▓▓▓▓▓▓▓▓▓▓▓▓▓ \n ***** //////// ▓▓▓▓▓▓▓ \n * ///////////// ▓▓▓ \n ▓▓ ////////////////// █ ▓▓ \n ▓▓ ▓▓ /////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ //////////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ /////////▓▓▓///////▓▓▓///////// ▓▓ ▓▓ \n ▓▓ ,////////////////////////////////////// ▓▓ ▓▓ \n ▓▓ ////////////////////////////////////////// ▓▓ \n ▓▓ //////////////////////▓▓▓▓///////////////////// \n ,//////////////////////////////////////////////////// \n .////////////////////////////////////////////////////////// \n .//////////////////////////██.,//////////////////////////█ \n .//////////////////////████..,./////////////////////██ \n ...////////////////███████.....,.////////////////███ \n ,.,////////////████████ ........,///////////████ \n .,.,//////█████████ ,.......///////████ \n ,..//████████ ........./████ \n ..,██████ .....,███ \n .██ ,.,█ \n \n \n \n ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ \n ▓▓▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ▓▓▓▓ \n ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓▓▓▓ \n ▓▓▓ ▓▓ ▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ \n*/\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\nimport \"./interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./interfaces/external/IWETH9.sol\";\nimport \"./interfaces/ICoreBorrow.sol\";\nimport \"./interfaces/ILiquidityGauge.sol\";\nimport \"./interfaces/ISwapper.sol\";\nimport \"./interfaces/IVaultManager.sol\";\n\n// ============================== STRUCTS AND ENUM =============================\n\n/// @notice Action types\nenum ActionType {\n transfer,\n wrapNative,\n unwrapNative,\n sweep,\n sweepNative,\n uniswapV3,\n oneInch,\n claimRewards,\n gaugeDeposit,\n borrower,\n swapper,\n mint4626,\n deposit4626,\n redeem4626,\n withdraw4626,\n // Deprecated\n prepareRedeemSavingsRate,\n // Deprecated\n claimRedeemSavingsRate,\n swapIn,\n swapOut,\n claimWeeklyInterest,\n withdraw,\n // Deprecated\n mint,\n deposit,\n // Deprecated\n openPerpetual,\n // Deprecated\n addToPerpetual,\n veANGLEDeposit,\n claimRewardsWithPerps\n}\n\n/// @notice Data needed to get permits\nstruct PermitType {\n address token;\n address owner;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @notice Data to grant permit to the router for a vault\nstruct PermitVaultManagerType {\n address vaultManager;\n address owner;\n bool approved;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @title BaseRouter\n/// @author Angle Core Team\n/// @notice Base contract that Angle router contracts on different chains should override\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\nabstract contract BaseRouter is Initializable {\n using SafeERC20 for IERC20;\n\n // ================================= REFERENCES ================================\n\n /// @notice Core address handling access control\n ICoreBorrow public core;\n /// @notice Address of the router used for swaps\n IUniswapV3Router public uniswapV3Router;\n /// @notice Address of 1Inch router used for swaps\n address public oneInch;\n\n uint256[47] private __gap;\n\n // ============================== EVENTS / ERRORS ==============================\n\n error IncompatibleLengths();\n error InvalidReturnMessage();\n error NotApprovedOrOwner();\n error NotGovernor();\n error NotGovernorOrGuardian();\n error TooSmallAmountOut();\n error TransferFailed();\n error ZeroAddress();\n\n /// @notice Deploys the router contract on a chain\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\n if (_core == address(0)) revert ZeroAddress();\n core = ICoreBorrow(_core);\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\n oneInch = _oneInch;\n }\n\n constructor() initializer {}\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Allows composable calls to different functions within the protocol\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\n /// @param actions List of actions to be performed by the router (in order of execution)\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\n /// for a given action are stored\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\n /// do not perform a sweep action on these tokens\n function mixer(\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) public payable virtual {\n // If all tokens have already been approved, there's no need for this step\n uint256 permitsLength = paramsPermit.length;\n for (uint256 i; i < permitsLength; ++i) {\n IERC20Permit(paramsPermit[i].token).permit(\n paramsPermit[i].owner,\n address(this),\n paramsPermit[i].value,\n paramsPermit[i].deadline,\n paramsPermit[i].v,\n paramsPermit[i].r,\n paramsPermit[i].s\n );\n }\n // Performing actions one after the others\n uint256 actionsLength = actions.length;\n for (uint256 i; i < actionsLength; ++i) {\n if (actions[i] == ActionType.transfer) {\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\n } else if (actions[i] == ActionType.wrapNative) {\n _wrapNative();\n } else if (actions[i] == ActionType.unwrapNative) {\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\n _unwrapNative(minAmountOut, to);\n } else if (actions[i] == ActionType.sweep) {\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\n _sweep(tokenOut, minAmountOut, to);\n } else if (actions[i] == ActionType.sweepNative) {\n uint256 routerBalance = address(this).balance;\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\n } else if (actions[i] == ActionType.uniswapV3) {\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\n data[i],\n (address, uint256, uint256, bytes)\n );\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\n } else if (actions[i] == ActionType.oneInch) {\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\n data[i],\n (address, uint256, bytes)\n );\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\n } else if (actions[i] == ActionType.claimRewards) {\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\n _claimRewards(user, claimLiquidityGauges);\n } else if (actions[i] == ActionType.gaugeDeposit) {\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\n data[i],\n (address, uint256, address, bool)\n );\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\n } else if (actions[i] == ActionType.borrower) {\n (\n address collateral,\n address vaultManager,\n address to,\n address who,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n bytes memory repayData\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\n } else if (actions[i] == ActionType.swapper) {\n (\n ISwapper swapperContract,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory payload\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\n } else if (actions[i] == ActionType.mint4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _mint4626(savingsRate, shares, to, maxAmountIn);\n } else if (actions[i] == ActionType.deposit4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _deposit4626(savingsRate, amount, to, minSharesOut);\n } else if (actions[i] == ActionType.redeem4626) {\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _redeem4626(savingsRate, shares, to, minAmountOut);\n } else if (actions[i] == ActionType.withdraw4626) {\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\n } else {\n _chainSpecificAction(actions[i], data[i]);\n }\n }\n }\n\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\n /// actions and then revoking this approval after these actions\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\n /// to revoke approvals\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\n /// is just an option\n function mixerVaultManagerPermit(\n PermitVaultManagerType[] memory paramsPermitVaultManager,\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) external payable virtual {\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n true,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n } else break;\n }\n mixer(paramsPermit, actions, data);\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\n // too deep\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (!paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n false,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n }\n }\n }\n\n receive() external payable {}\n\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\n\n /// @notice Wraps the native token of a chain to its wrapped version\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\n /// @dev The amount to wrap is to be specified in the `msg.value`\n function _wrapNative() internal virtual returns (uint256) {\n _getNativeWrapper().deposit{ value: msg.value }();\n return msg.value;\n }\n\n /// @notice Unwraps the wrapped version of a token to the native chain token\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\n amount = _getNativeWrapper().balanceOf(address(this));\n _slippageCheck(amount, minAmountOut);\n if (amount != 0) {\n _getNativeWrapper().withdraw(amount);\n _safeTransferNative(to, amount);\n }\n return amount;\n }\n\n /// @notice Internal version of the `claimRewards` function\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\n uint256 gaugesLength = liquidityGauges.length;\n for (uint256 i; i < gaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n }\n\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\n /// @param vaultManager Address of the vault to perform actions on\n /// @param actionsBorrow Actions type to perform on the vaultManager\n /// @param dataBorrow Data needed for each actions\n /// @param to Address to send the funds to\n /// @param who Swapper address to handle repayments\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\n function _angleBorrower(\n address vaultManager,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address to,\n address who,\n bytes memory repayData\n ) internal virtual returns (PaymentData memory paymentData) {\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\n }\n\n /// @notice Allows to deposit tokens into a gauge\n /// @param user Address on behalf of which deposits should be made in the gauge\n /// @param amount Amount to stake\n /// @param gauge Liquidity gauge to stake in\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\n /// @dev The function will revert if the gauge has not already been approved by the contract\n function _gaugeDeposit(\n address user,\n uint256 amount,\n ILiquidityGauge gauge,\n bool shouldClaimRewards\n ) internal virtual {\n gauge.deposit(amount, user, shouldClaimRewards);\n }\n\n /// @notice Sweeps tokens from the router contract\n /// @param tokenOut Token to sweep\n /// @param minAmountOut Minimum amount of tokens to recover\n /// @param to Address to which tokens should be sent\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\n _slippageCheck(balanceToken, minAmountOut);\n if (balanceToken != 0) {\n IERC20(tokenOut).safeTransfer(to, balanceToken);\n }\n }\n\n /// @notice Uses an external swapper\n /// @param swapper Contracts implementing the logic of the swap\n /// @param inToken Token used to do the swap\n /// @param outToken Token wanted\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\n /// @param inTokenObtained Amount of `inToken` used for the swap\n /// @param data Additional info for the specific swapper\n function _swapper(\n ISwapper swapper,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) internal {\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\n }\n\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\n /// @param inToken Token used as entrance of the swap\n /// @param amount Amount of in token to swap\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\n function _swapOnUniswapV3(\n IERC20 inToken,\n uint256 amount,\n uint256 minAmountOut,\n bytes memory path\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `uniswapV3Router`\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address uniRouter = address(uniswapV3Router);\n _changeAllowance(IERC20(inToken), uniRouter, type(uint256).max);\n amountOut = IUniswapV3Router(uniRouter).exactInput(\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\n );\n }\n\n /// @notice Swaps an inToken to another token via 1Inch Router\n /// @param payload Bytes needed for 1Inch router to process the swap\n /// @dev The `payload` given is expected to be obtained from 1Inch API\n function _swapOn1Inch(\n IERC20 inToken,\n uint256 minAmountOut,\n bytes memory payload\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `oneInch` address\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address oneInchRouter = oneInch;\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\n //solhint-disable-next-line\n (bool success, bytes memory result) = oneInchRouter.call(payload);\n if (!success) _revertBytes(result);\n\n amountOut = abi.decode(result, (uint256));\n _slippageCheck(amountOut, minAmountOut);\n }\n\n /// @notice Mints `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to mint shares from\n /// @param shares Amount of shares to mint from the contract\n /// @param to Address to which shares should be sent\n /// @param maxAmountIn Max amount of assets used to mint\n /// @return amountIn Amount of assets used to mint by `to`\n function _mint4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 maxAmountIn\n ) internal returns (uint256 amountIn) {\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\n }\n\n /// @notice Deposits `amount` to an ERC4626 contract\n /// @param savingsRate The ERC4626 to deposit assets to\n /// @param amount Amount of assets to deposit\n /// @param to Address to which shares should be sent\n /// @param minSharesOut Minimum amount of shares that `to` should received\n /// @return sharesOut Amount of shares received by `to`\n function _deposit4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\n }\n\n /// @notice Withdraws `amount` from an ERC4626 contract\n /// @param savingsRate ERC4626 to withdraw assets from\n /// @param amount Amount of assets to withdraw\n /// @param to Destination of assets\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\n /// @return sharesOut Amount of shares burnt\n function _withdraw4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 maxSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\n }\n\n /// @notice Redeems `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to redeem shares from\n /// @param shares Amount of shares to redeem\n /// @param to Destination of assets\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\n /// @return amountOut Amount of assets received by `to`\n function _redeem4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 minAmountOut\n ) internal returns (uint256 amountOut) {\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\n }\n\n /// @notice Allows to perform some specific actions for a chain\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\n\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\n\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\n\n // ============================ GOVERNANCE FUNCTION ============================\n\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\n modifier onlyGovernorOrGuardian() {\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n _;\n }\n\n /// @notice Sets a new `core` contract\n function setCore(ICoreBorrow _core) external {\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\n core = ICoreBorrow(_core);\n }\n\n /// @notice Changes allowances for different tokens\n /// @param tokens Addresses of the tokens to allow\n /// @param spenders Addresses to allow transfer\n /// @param amounts Amounts to allow\n function changeAllowance(\n IERC20[] calldata tokens,\n address[] calldata spenders,\n uint256[] calldata amounts\n ) external onlyGovernorOrGuardian {\n uint256 tokensLength = tokens.length;\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\n for (uint256 i; i < tokensLength; ++i) {\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\n }\n }\n\n /// @notice Sets a new router variable\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\n if (router == address(0)) revert ZeroAddress();\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\n else oneInch = router;\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Changes allowance of this contract for a given token\n /// @param token Address of the token to change allowance\n /// @param spender Address to change the allowance of\n /// @param amount Amount allowed\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\n uint256 currentAllowance = token.allowance(address(this), spender);\n // In case `currentAllowance < type(uint256).max / 2` and we want to increase it:\n // Do nothing (to handle tokens that need reapprovals to 0 and save gas)\n if (currentAllowance < amount && currentAllowance < type(uint256).max / 2) {\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\n } else if (currentAllowance > amount) {\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\n }\n }\n\n /// @notice Transfer amount of the native token to the `to` address\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\n function _safeTransferNative(address to, uint256 amount) internal {\n bool success;\n //solhint-disable-next-line\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n if (!success) revert TransferFailed();\n }\n\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\n /// the calling address is well approved for all the vaults with which it is interacting\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\n /// with a vault are approved for this vault\n function _parseVaultIDs(\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address vaultManager,\n address collateral\n ) internal view returns (bytes[] memory) {\n uint256 actionsBorrowLength = actionsBorrow.length;\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\n bool createVaultAction;\n uint256 lastVaultID;\n uint256 vaultIDLength;\n for (uint256 i; i < actionsBorrowLength; ++i) {\n uint256 vaultID;\n // If there is a `createVault` action, the router should not worry about looking at\n // next vaultIDs given equal to 0\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\n createVaultAction = true;\n continue;\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\n // as collateral the full contract balance\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\n uint256 amount;\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\n if (amount == type(uint256).max)\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\n continue;\n // There are different ways depending on the action to find the `vaultID` to parse\n } else if (\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\n ) {\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\n vaultID = abi.decode(dataBorrow[i], (uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\n } else continue;\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\n // if there has not been any specific action\n if (vaultID == 0) {\n if (createVaultAction) {\n continue;\n } else {\n // If we haven't stored the last `vaultID`, we need to fetch it\n if (lastVaultID == 0) {\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\n }\n vaultID = lastVaultID;\n }\n }\n\n // Check if this `vaultID` has already been verified\n for (uint256 j; j < vaultIDLength; ++j) {\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\n // If yes, we continue to the next iteration\n continue;\n }\n }\n // Verify this new `vaultID` and add it to the list\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\n revert NotApprovedOrOwner();\n }\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\n vaultIDLength += 1;\n }\n return dataBorrow;\n }\n\n /// @notice Checks whether the amount obtained during a swap is not too small\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\n if (amount < thresholdAmount) revert TooSmallAmountOut();\n }\n\n /// @notice Internal function used for error handling\n function _revertBytes(bytes memory errMsg) internal pure {\n if (errMsg.length != 0) {\n //solhint-disable-next-line\n assembly {\n revert(add(32, errMsg), mload(errMsg))\n }\n }\n revert InvalidReturnMessage();\n }\n}\n" + }, + "contracts/implementations/base/AngleRouterBase.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterBase\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Base\ncontract AngleRouterBase is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n /// @dev There is no wCELO contract on CELO\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x4200000000000000000000000000000000000006);\n }\n}\n" + }, + "contracts/interfaces/external/IWETH9.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n /// @notice Deposit ether to get wrapped ether\n function deposit() external payable;\n\n /// @notice Withdraw wrapped ether to get ether\n function withdraw(uint256) external;\n}\n" + }, + "contracts/interfaces/external/uniswap/IUniswapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nstruct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n}\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IUniswapV3Router {\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\n/// @title Router for price estimation functionality\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\n/// @dev This interface is only used for non critical elements of the protocol\ninterface IUniswapV2Router {\n /// @notice Given an input asset amount, returns the maximum output amount of the\n /// other asset (accounting for fees) given reserves.\n /// @param path Addresses of the pools used to get prices\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 swapAmount,\n uint256 minExpected,\n address[] calldata path,\n address receiver,\n uint256 swapDeadline\n ) external;\n}\n" + }, + "contracts/interfaces/IAgTokenMultiChain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IAgTokenMultiChain\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\ninterface IAgTokenMultiChain {\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n}\n" + }, + "contracts/interfaces/ICoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ICoreBorrow\n/// @author Angle Core Team\n/// @notice Interface for the `CoreBorrow` contract\n\ninterface ICoreBorrow {\n /// @notice Checks whether an address is governor of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\n function isGovernor(address admin) external view returns (bool);\n\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\n /// role by calling the `addGovernor` function\n function isGovernorOrGuardian(address admin) external view returns (bool);\n}\n" + }, + "contracts/interfaces/ILiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface ILiquidityGauge {\n // solhint-disable-next-line\n function staking_token() external returns (address stakingToken);\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external;\n}\n" + }, + "contracts/interfaces/ISwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\n\n/// @title ISwapper\n/// @author Angle Core Team\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\ninterface ISwapper {\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) external;\n}\n" + }, + "contracts/interfaces/ITreasury.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ITreasury\n/// @author Angle Core Team\n/// @notice Interface for the `Treasury` contract\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\n/// of this module\ninterface ITreasury {\n /// @notice Checks whether a given address has well been initialized in this contract\n /// as a `VaultManager``\n /// @param _vaultManager Address to check\n /// @return Whether the address has been initialized or not\n function isVaultManager(address _vaultManager) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./ITreasury.sol\";\n\n// ========================= Key Structs and Enums =============================\n\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\n/// to the caller or associated addresses\nstruct PaymentData {\n // Stablecoin amount the contract should give\n uint256 stablecoinAmountToGive;\n // Stablecoin amount owed to the contract\n uint256 stablecoinAmountToReceive;\n // Collateral amount the contract should give\n uint256 collateralAmountToGive;\n // Collateral amount owed to the contract\n uint256 collateralAmountToReceive;\n}\n\n/// @notice Data stored to track someone's loan (or equivalently called position)\nstruct Vault {\n // Amount of collateral deposited in the vault\n uint256 collateralAmount;\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\n uint256 normalizedDebt;\n}\n\n/// @notice Actions possible when composing calls to the different entry functions proposed\nenum ActionBorrowType {\n createVault,\n closeVault,\n addCollateral,\n removeCollateral,\n repayDebt,\n borrow,\n getDebtIn,\n permit\n}\n\n// ========================= Interfaces =============================\n\n/// @title IVaultManagerFunctions\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface only contains functions of the contract which are called by other contracts\n/// of this module (without getters)\ninterface IVaultManagerFunctions {\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\n /// @param repayData Data to pass to the repayment contract in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approved Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approved,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n\n/// @title IVaultManagerStorage\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface contains getters of the contract's public variables used by other contracts\n/// of this module\ninterface IVaultManagerStorage {\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\n function treasury() external view returns (ITreasury);\n\n /// @notice Reference to the collateral handled by this `VaultManager`\n function collateral() external view returns (IERC20);\n\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\n function vaultIDCount() external view returns (uint256);\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "devdoc", + "userdoc" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/celo/.chainId b/deployments/celo/.chainId new file mode 100644 index 0000000..2a9e2d3 --- /dev/null +++ b/deployments/celo/.chainId @@ -0,0 +1 @@ +42220 \ No newline at end of file diff --git a/deployments/celo/AngleRouterCeloV2.json b/deployments/celo/AngleRouterCeloV2.json new file mode 100644 index 0000000..d5957d1 --- /dev/null +++ b/deployments/celo/AngleRouterCeloV2.json @@ -0,0 +1,247 @@ +{ + "address": "0x81Ac0F2E39088C73Dce9b354fdC6c302e9f2836D", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xad5344f861bdb707ef92bd23c6afd9522ca30fc72733cc5be9f36ea86121863e", + "receipt": { + "to": null, + "from": "0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185", + "contractAddress": "0x81Ac0F2E39088C73Dce9b354fdC6c302e9f2836D", + "transactionIndex": 4, + "gasUsed": "718558", + "logsBloom": "0x00000000000000000000200000000000400000000000100000000000000800000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000010000000000000000000000000020000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000020000", + "blockHash": "0x25658acd886a4900304bfeb6199f45a51d8d76e8e6326310daf91f7b1d1da47a", + "transactionHash": "0xad5344f861bdb707ef92bd23c6afd9522ca30fc72733cc5be9f36ea86121863e", + "logs": [ + { + "transactionIndex": 4, + "blockNumber": 23689080, + "transactionHash": "0xad5344f861bdb707ef92bd23c6afd9522ca30fc72733cc5be9f36ea86121863e", + "address": "0x81Ac0F2E39088C73Dce9b354fdC6c302e9f2836D", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000db2fd6a9f5138246c6dfa1b8a1d5f366cc638b46" + ], + "data": "0x", + "logIndex": 5, + "blockHash": "0x25658acd886a4900304bfeb6199f45a51d8d76e8e6326310daf91f7b1d1da47a" + }, + { + "transactionIndex": 4, + "blockNumber": 23689080, + "transactionHash": "0xad5344f861bdb707ef92bd23c6afd9522ca30fc72733cc5be9f36ea86121863e", + "address": "0x81Ac0F2E39088C73Dce9b354fdC6c302e9f2836D", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 6, + "blockHash": "0x25658acd886a4900304bfeb6199f45a51d8d76e8e6326310daf91f7b1d1da47a" + }, + { + "transactionIndex": 4, + "blockNumber": 23689080, + "transactionHash": "0xad5344f861bdb707ef92bd23c6afd9522ca30fc72733cc5be9f36ea86121863e", + "address": "0x81Ac0F2E39088C73Dce9b354fdC6c302e9f2836D", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a5b060bd7b8f86c4c0d720a17367729670afb19", + "logIndex": 7, + "blockHash": "0x25658acd886a4900304bfeb6199f45a51d8d76e8e6326310daf91f7b1d1da47a" + } + ], + "blockNumber": 23689080, + "cumulativeGasUsed": "1059798", + "status": 1, + "byzantium": true + }, + "args": [ + "0xdb2Fd6a9f5138246C6dfa1b8A1D5f366cc638B46", + "0x9a5b060Bd7b8f86c4C0D720a17367729670AfB19", + "0x42860d4b00000000000000000000000059153e939c5b4721543251ff3049ea04c755373b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "numDeployments": 1, + "solcInputHash": "382e5f7965175dcf029b988f27abf9db", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin `TransparentUpgradeableProxy` To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/external/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"},\"contracts/external/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin\\n * `TransparentUpgradeableProxy`\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xdbb2775fbc740793c0b3d5927cca8b9976cc4f9caef50178d1be0aa7afca14e6\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x6080604052604051620010bb380380620010bb8339810160408190526200002691620004d8565b828162000036828260006200009a565b5062000066905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6104620005b8565b6000805160206200107483398151915214620000865762000086620005da565b6200009182620000d7565b50505062000643565b620000a58362000132565b600082511180620000b35750805b15620000d257620000d083836200017460201b6200028c1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f62000102620001a5565b604080516001600160a01b03928316815291841660208301520160405180910390a16200012f81620001de565b50565b6200013d8162000293565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200019c8383604051806060016040528060278152602001620010946027913962000347565b90505b92915050565b6000620001cf6000805160206200107483398151915260001b6200042f60201b6200022e1760201c565b546001600160a01b0316919050565b6001600160a01b038116620002495760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002726000805160206200107483398151915260001b6200042f60201b6200022e1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b620002a9816200043260201b620002b81760201c565b6200030d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840162000240565b80620002727f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b6200042f60201b6200022e1760201c565b60606001600160a01b0384163b620003b15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840162000240565b600080856001600160a01b031685604051620003ce9190620005f0565b600060405180830381855af49150503d80600081146200040b576040519150601f19603f3d011682016040523d82523d6000602084013e62000410565b606091505b5090925090506200042382828662000441565b925050505b9392505050565b90565b6001600160a01b03163b151590565b606083156200045257508162000428565b825115620004635782518084602001fd5b8160405162461bcd60e51b81526004016200024091906200060e565b80516001600160a01b03811681146200049757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004cf578181015183820152602001620004b5565b50506000910152565b600080600060608486031215620004ee57600080fd5b620004f9846200047f565b925062000509602085016200047f565b60408501519092506001600160401b03808211156200052757600080fd5b818601915086601f8301126200053c57600080fd5b8151818111156200055157620005516200049c565b604051601f8201601f19908116603f011681019083821181831017156200057c576200057c6200049c565b816040528281528960208487010111156200059657600080fd5b620005a9836020830160208801620004b2565b80955050505050509250925092565b818103818111156200019f57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052600160045260246000fd5b6000825162000604818460208701620004b2565b9190910192915050565b60208152600082518060208401526200062f816040850160208701620004b2565b601f01601f19169190910160400192915050565b610a2180620006536000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109c5602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105739190610957565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610973565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b50506000910152565b60008251610969818460208701610933565b9190910192915050565b6020815260008251806020840152610992816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051812c356928ef88014789eaeb04ce9454e2ec8e03025a1ceedcece2f91bca8964736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b610090366004610895565b610135565b61006b6100a33660046108b0565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b610101366004610895565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109c5602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b60006102216105cd565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b610422836105f5565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161017481610642565b606073ffffffffffffffffffffffffffffffffffffffff84163b61054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016103a2565b6000808573ffffffffffffffffffffffffffffffffffffffff16856040516105739190610957565b600060405180830381855af49150503d80600081146105ae576040519150601f19603f3d011682016040523d82523d6000602084013e6105b3565b606091505b50915091506105c382828661074e565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b6105fe816107a1565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff81166106e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561075d5750816102b1565b82511561076d5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610973565b73ffffffffffffffffffffffffffffffffffffffff81163b610845576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610708565b803573ffffffffffffffffffffffffffffffffffffffff8116811461089057600080fd5b919050565b6000602082840312156108a757600080fd5b6102b18261086c565b6000806000604084860312156108c557600080fd5b6108ce8461086c565b9250602084013567ffffffffffffffff808211156108eb57600080fd5b818601915086601f8301126108ff57600080fd5b81358181111561090e57600080fd5b87602082850101111561092057600080fd5b6020830194508093505050509250925092565b60005b8381101561094e578181015183820152602001610936565b50506000910152565b60008251610969818460208701610933565b9190910192915050565b6020815260008251806020840152610992816040850160208701610933565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122051812c356928ef88014789eaeb04ce9454e2ec8e03025a1ceedcece2f91bca8964736f6c63430008110033", + "devdoc": { + "details": "This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin `TransparentUpgradeableProxy` To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "kind": "dev", + "methods": { + "admin()": { + "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" + }, + "changeAdmin(address)": { + "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." + }, + "constructor": { + "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." + }, + "implementation()": { + "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" + }, + "upgradeTo(address)": { + "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." + }, + "upgradeToAndCall(address,bytes)": { + "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/deployments/celo/AngleRouterCeloV2_1_Implementation.json b/deployments/celo/AngleRouterCeloV2_1_Implementation.json new file mode 100644 index 0000000..3cf16d3 --- /dev/null +++ b/deployments/celo/AngleRouterCeloV2_1_Implementation.json @@ -0,0 +1,556 @@ +{ + "address": "0xdb2Fd6a9f5138246C6dfa1b8A1D5f366cc638B46", + "abi": [ + { + "inputs": [], + "name": "IncompatibleLengths", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidReturnMessage", + "type": "error" + }, + { + "inputs": [], + "name": "NotApprovedOrOwner", + "type": "error" + }, + { + "inputs": [], + "name": "NotGovernor", + "type": "error" + }, + { + "inputs": [], + "name": "NotGovernorOrGuardian", + "type": "error" + }, + { + "inputs": [], + "name": "TooSmallAmountOut", + "type": "error" + }, + { + "inputs": [], + "name": "TransferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "spenders", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "changeAllowance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "gaugeUser", + "type": "address" + }, + { + "internalType": "address[]", + "name": "liquidityGauges", + "type": "address[]" + } + ], + "name": "claimRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "core", + "outputs": [ + { + "internalType": "contract ICoreBorrow", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_core", + "type": "address" + }, + { + "internalType": "address", + "name": "_uniswapRouter", + "type": "address" + }, + { + "internalType": "address", + "name": "_oneInch", + "type": "address" + } + ], + "name": "initializeRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitType[]", + "name": "paramsPermit", + "type": "tuple[]" + }, + { + "internalType": "enum ActionType[]", + "name": "actions", + "type": "uint8[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "mixer", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "vaultManager", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitVaultManagerType[]", + "name": "paramsPermitVaultManager", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct PermitType[]", + "name": "paramsPermit", + "type": "tuple[]" + }, + { + "internalType": "enum ActionType[]", + "name": "actions", + "type": "uint8[]" + }, + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "mixerVaultManagerPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "oneInch", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ICoreBorrow", + "name": "_core", + "type": "address" + } + ], + "name": "setCore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "router", + "type": "address" + }, + { + "internalType": "uint8", + "name": "who", + "type": "uint8" + } + ], + "name": "setRouter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "uniswapV3Router", + "outputs": [ + { + "internalType": "contract IUniswapV3Router", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x75e4a74bfe698e9a25bf9b43d448cd4ab65e0fe79638fd8c21dfbff3d04b76ec", + "receipt": { + "to": null, + "from": "0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185", + "contractAddress": "0xdb2Fd6a9f5138246C6dfa1b8A1D5f366cc638B46", + "transactionIndex": 4, + "gasUsed": "3790511", + "logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000400000000000000000000000000020000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x40a78843cd1dcfdc2fe19f77694a3a416dfd3f824501e8178b4889138d76353b", + "transactionHash": "0x75e4a74bfe698e9a25bf9b43d448cd4ab65e0fe79638fd8c21dfbff3d04b76ec", + "logs": [ + { + "transactionIndex": 4, + "blockNumber": 23689079, + "transactionHash": "0x75e4a74bfe698e9a25bf9b43d448cd4ab65e0fe79638fd8c21dfbff3d04b76ec", + "address": "0xdb2Fd6a9f5138246C6dfa1b8A1D5f366cc638B46", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 38, + "blockHash": "0x40a78843cd1dcfdc2fe19f77694a3a416dfd3f824501e8178b4889138d76353b" + } + ], + "blockNumber": 23689079, + "cumulativeGasUsed": "4960150", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "d2039b63af7039fcdbc036f20229f89c", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"IncompatibleLengths\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidReturnMessage\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotApprovedOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotGovernor\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotGovernorOrGuardian\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TooSmallAmountOut\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TransferFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IERC20[]\",\"name\":\"tokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"spenders\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"changeAllowance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gaugeUser\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"liquidityGauges\",\"type\":\"address[]\"}],\"name\":\"claimRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"core\",\"outputs\":[{\"internalType\":\"contract ICoreBorrow\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_core\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_uniswapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_oneInch\",\"type\":\"address\"}],\"name\":\"initializeRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitType[]\",\"name\":\"paramsPermit\",\"type\":\"tuple[]\"},{\"internalType\":\"enum ActionType[]\",\"name\":\"actions\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"mixer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"vaultManager\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitVaultManagerType[]\",\"name\":\"paramsPermitVaultManager\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct PermitType[]\",\"name\":\"paramsPermit\",\"type\":\"tuple[]\"},{\"internalType\":\"enum ActionType[]\",\"name\":\"actions\",\"type\":\"uint8[]\"},{\"internalType\":\"bytes[]\",\"name\":\"data\",\"type\":\"bytes[]\"}],\"name\":\"mixerVaultManagerPermit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oneInch\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ICoreBorrow\",\"name\":\"_core\",\"type\":\"address\"}],\"name\":\"setCore\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router\",\"type\":\"address\"},{\"internalType\":\"uint8\",\"name\":\"who\",\"type\":\"uint8\"}],\"name\":\"setRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"uniswapV3Router\",\"outputs\":[{\"internalType\":\"contract IUniswapV3Router\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"author\":\"Angle Core Team\",\"kind\":\"dev\",\"methods\":{\"changeAllowance(address[],address[],uint256[])\":{\"params\":{\"amounts\":\"Amounts to allow\",\"spenders\":\"Addresses to allow transfer\",\"tokens\":\"Addresses of the tokens to allow\"}},\"claimRewards(address,address[])\":{\"details\":\"If the caller wants to send the rewards to another account it first needs to call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\",\"params\":{\"gaugeUser\":\"Address for which to fetch the rewards from the gauges\",\"liquidityGauges\":\"Gauges to claim on\"}},\"mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"details\":\"With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol does not verify the payload given and cannot check that the swap performed by users actually gives the desired out token: in this case funds may be made accessible to anyone on this contract if the concerned users do not perform a sweep action on these tokens\",\"params\":{\"actions\":\"List of actions to be performed by the router (in order of execution)\",\"data\":\"Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters for a given action are stored\",\"paramsPermit\":\"Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\"}},\"mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"details\":\"In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures to revoke approvalsThe router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this is just an option\",\"params\":{\"paramsPermitVaultManager\":\"Parameters to sign permit to give allowance to the router for a `VaultManager` contract\"}}},\"title\":\"AngleRouterCelo\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"changeAllowance(address[],address[],uint256[])\":{\"notice\":\"Changes allowances for different tokens\"},\"claimRewards(address,address[])\":{\"notice\":\"Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple gauges at once\"},\"core()\":{\"notice\":\"Core address handling access control\"},\"initializeRouter(address,address,address)\":{\"notice\":\"Deploys the router contract on a chain\"},\"mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"notice\":\"Allows composable calls to different functions within the protocol\"},\"mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])\":{\"notice\":\"Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing actions and then revoking this approval after these actions\"},\"oneInch()\":{\"notice\":\"Address of 1Inch router used for swaps\"},\"setCore(address)\":{\"notice\":\"Sets a new `core` contract\"},\"setRouter(address,uint8)\":{\"notice\":\"Sets a new router variable\"},\"uniswapV3Router()\":{\"notice\":\"Address of the router used for swaps\"}},\"notice\":\"Router contract built specifially for Angle use cases on Celo\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/implementations/celo/AngleRouterCelo.sol\":\"AngleRouterCelo\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0203dcadc5737d9ef2c211d6fa15d18ebc3b30dfa51903b64870b01a062b0b4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0x611aa3f23e59cfdd1863c536776407b3e33d695152a266fa7cfb34440a29a8a3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../token/ERC20/IERC20.sol\\\";\\n\",\"keccak256\":\"0x6ebf1944ab804b8660eb6fc52f9fe84588cee01c2566a69023e59497e7d27f45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../token/ERC20/IERC20.sol\\\";\\nimport \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n *\\n * _Available since v4.7._\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x9750c6fec736eb3320e85924f36a3060fa4a4ab1758d06d9585e175d164eefdb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\\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 function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-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 function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) 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(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) 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 function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\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 if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x032807210d1d7d218963d7355d62e021a84bf1b3339f4f50be2f63b53cccaf29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.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 *\\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \\\"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(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) 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 require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(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 require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason 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 // 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}\\n\",\"keccak256\":\"0xd6153ce99bcdcce22b124f755e72553295be6abcd63804cfdffceb188b8bef10\",\"license\":\"MIT\"},\"contracts/BaseAngleRouterSidechain.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"./interfaces/IAgTokenMultiChain.sol\\\";\\nimport \\\"./BaseRouter.sol\\\";\\n\\n/// @title BaseAngleRouterSidechain\\n/// @author Angle Core Team\\n/// @notice Extension of the `BaseRouter` contract for sidechains\\nabstract contract BaseAngleRouterSidechain is BaseRouter {\\n // =========================== ROUTER FUNCTIONALITIES ==========================\\n\\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\\n /// gauges at once\\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\\n /// @param liquidityGauges Gauges to claim on\\n /// @dev If the caller wants to send the rewards to another account it first needs to\\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\\n _claimRewards(gaugeUser, liquidityGauges);\\n }\\n\\n /// @inheritdoc BaseRouter\\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\\n if (action == ActionType.swapIn) {\\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\\n .decode(data, (address, address, uint256, uint256, address));\\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\\n } else if (action == ActionType.swapOut) {\\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\\n .decode(data, (address, address, uint256, uint256, address));\\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\\n }\\n }\\n\\n /// @notice Wraps a bridge token to its corresponding canonical version\\n function _swapIn(\\n address canonicalToken,\\n address bridgeToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n address to\\n ) internal returns (uint256) {\\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\\n _slippageCheck(amount, minAmountOut);\\n return amount;\\n }\\n\\n /// @notice Unwraps a canonical token for one of its bridge version\\n function _swapOut(\\n address canonicalToken,\\n address bridgeToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n address to\\n ) internal returns (uint256) {\\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\\n _slippageCheck(amount, minAmountOut);\\n return amount;\\n }\\n}\\n\",\"keccak256\":\"0xe3503193ad3da691e6308881cf8e87dbe1f1714b5474c8b66aadf8764c2c5116\",\"license\":\"GPL-3.0\"},\"contracts/BaseRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\n/*\\n * \\u2588 \\n ***** \\u2593\\u2593\\u2593 \\n * \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n * ///. \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n ***** //////// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n * ///////////// \\u2593\\u2593\\u2593 \\n \\u2593\\u2593 ////////////////// \\u2588 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 /////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 //////////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 \\u2593\\u2593 /////////\\u2593\\u2593\\u2593///////\\u2593\\u2593\\u2593///////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 ,////////////////////////////////////// \\u2593\\u2593 \\u2593\\u2593 \\n \\u2593\\u2593 ////////////////////////////////////////// \\u2593\\u2593 \\n \\u2593\\u2593 //////////////////////\\u2593\\u2593\\u2593\\u2593///////////////////// \\n ,//////////////////////////////////////////////////// \\n .////////////////////////////////////////////////////////// \\n .//////////////////////////\\u2588\\u2588.,//////////////////////////\\u2588 \\n .//////////////////////\\u2588\\u2588\\u2588\\u2588..,./////////////////////\\u2588\\u2588 \\n ...////////////////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588.....,.////////////////\\u2588\\u2588\\u2588 \\n ,.,////////////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ........,///////////\\u2588\\u2588\\u2588\\u2588 \\n .,.,//////\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ,.......///////\\u2588\\u2588\\u2588\\u2588 \\n ,..//\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 ........./\\u2588\\u2588\\u2588\\u2588 \\n ..,\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 .....,\\u2588\\u2588\\u2588 \\n .\\u2588\\u2588 ,.,\\u2588 \\n \\n \\n \\n \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\n \\u2593\\u2593\\u2593 \\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\n*/\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\nimport \\\"./interfaces/external/uniswap/IUniswapRouter.sol\\\";\\nimport \\\"./interfaces/external/IWETH9.sol\\\";\\nimport \\\"./interfaces/ICoreBorrow.sol\\\";\\nimport \\\"./interfaces/ILiquidityGauge.sol\\\";\\nimport \\\"./interfaces/ISwapper.sol\\\";\\nimport \\\"./interfaces/IVaultManager.sol\\\";\\n\\n// ============================== STRUCTS AND ENUM =============================\\n\\n/// @notice Action types\\nenum ActionType {\\n transfer,\\n wrapNative,\\n unwrapNative,\\n sweep,\\n sweepNative,\\n uniswapV3,\\n oneInch,\\n claimRewards,\\n gaugeDeposit,\\n borrower,\\n swapper,\\n mint4626,\\n deposit4626,\\n redeem4626,\\n withdraw4626,\\n // Deprecated\\n prepareRedeemSavingsRate,\\n // Deprecated\\n claimRedeemSavingsRate,\\n swapIn,\\n swapOut,\\n claimWeeklyInterest,\\n withdraw,\\n // Deprecated\\n mint,\\n deposit,\\n // Deprecated\\n openPerpetual,\\n // Deprecated\\n addToPerpetual,\\n veANGLEDeposit,\\n claimRewardsWithPerps\\n}\\n\\n/// @notice Data needed to get permits\\nstruct PermitType {\\n address token;\\n address owner;\\n uint256 value;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\n/// @notice Data to grant permit to the router for a vault\\nstruct PermitVaultManagerType {\\n address vaultManager;\\n address owner;\\n bool approved;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\n/// @title BaseRouter\\n/// @author Angle Core Team\\n/// @notice Base contract that Angle router contracts on different chains should override\\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\\nabstract contract BaseRouter is Initializable {\\n using SafeERC20 for IERC20;\\n\\n // ================================= REFERENCES ================================\\n\\n /// @notice Core address handling access control\\n ICoreBorrow public core;\\n /// @notice Address of the router used for swaps\\n IUniswapV3Router public uniswapV3Router;\\n /// @notice Address of 1Inch router used for swaps\\n address public oneInch;\\n\\n uint256[47] private __gap;\\n\\n // ============================== EVENTS / ERRORS ==============================\\n\\n error IncompatibleLengths();\\n error InvalidReturnMessage();\\n error NotApprovedOrOwner();\\n error NotGovernor();\\n error NotGovernorOrGuardian();\\n error TooSmallAmountOut();\\n error TransferFailed();\\n error ZeroAddress();\\n\\n /// @notice Deploys the router contract on a chain\\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\\n if (_core == address(0)) revert ZeroAddress();\\n core = ICoreBorrow(_core);\\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\\n oneInch = _oneInch;\\n }\\n\\n constructor() initializer {}\\n\\n // =========================== ROUTER FUNCTIONALITIES ==========================\\n\\n /// @notice Allows composable calls to different functions within the protocol\\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\\n /// @param actions List of actions to be performed by the router (in order of execution)\\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\\n /// for a given action are stored\\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\\n /// do not perform a sweep action on these tokens\\n function mixer(\\n PermitType[] memory paramsPermit,\\n ActionType[] calldata actions,\\n bytes[] calldata data\\n ) public payable virtual {\\n // If all tokens have already been approved, there's no need for this step\\n uint256 permitsLength = paramsPermit.length;\\n for (uint256 i; i < permitsLength; ++i) {\\n IERC20Permit(paramsPermit[i].token).permit(\\n paramsPermit[i].owner,\\n address(this),\\n paramsPermit[i].value,\\n paramsPermit[i].deadline,\\n paramsPermit[i].v,\\n paramsPermit[i].r,\\n paramsPermit[i].s\\n );\\n }\\n // Performing actions one after the others\\n uint256 actionsLength = actions.length;\\n for (uint256 i; i < actionsLength; ++i) {\\n if (actions[i] == ActionType.transfer) {\\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\\n } else if (actions[i] == ActionType.wrapNative) {\\n _wrapNative();\\n } else if (actions[i] == ActionType.unwrapNative) {\\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\\n _unwrapNative(minAmountOut, to);\\n } else if (actions[i] == ActionType.sweep) {\\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\\n _sweep(tokenOut, minAmountOut, to);\\n } else if (actions[i] == ActionType.sweepNative) {\\n uint256 routerBalance = address(this).balance;\\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\\n } else if (actions[i] == ActionType.uniswapV3) {\\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\\n data[i],\\n (address, uint256, uint256, bytes)\\n );\\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\\n } else if (actions[i] == ActionType.oneInch) {\\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\\n data[i],\\n (address, uint256, bytes)\\n );\\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\\n } else if (actions[i] == ActionType.claimRewards) {\\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\\n _claimRewards(user, claimLiquidityGauges);\\n } else if (actions[i] == ActionType.gaugeDeposit) {\\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\\n data[i],\\n (address, uint256, address, bool)\\n );\\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\\n } else if (actions[i] == ActionType.borrower) {\\n (\\n address collateral,\\n address vaultManager,\\n address to,\\n address who,\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n bytes memory repayData\\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\\n } else if (actions[i] == ActionType.swapper) {\\n (\\n ISwapper swapperContract,\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory payload\\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\\n } else if (actions[i] == ActionType.mint4626) {\\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\\n data[i],\\n (IERC20, IERC4626, uint256, address, uint256)\\n );\\n _changeAllowance(token, address(savingsRate), type(uint256).max);\\n _mint4626(savingsRate, shares, to, maxAmountIn);\\n } else if (actions[i] == ActionType.deposit4626) {\\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\\n data[i],\\n (IERC20, IERC4626, uint256, address, uint256)\\n );\\n _changeAllowance(token, address(savingsRate), type(uint256).max);\\n _deposit4626(savingsRate, amount, to, minSharesOut);\\n } else if (actions[i] == ActionType.redeem4626) {\\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\\n data[i],\\n (IERC4626, uint256, address, uint256)\\n );\\n _redeem4626(savingsRate, shares, to, minAmountOut);\\n } else if (actions[i] == ActionType.withdraw4626) {\\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\\n data[i],\\n (IERC4626, uint256, address, uint256)\\n );\\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\\n } else {\\n _chainSpecificAction(actions[i], data[i]);\\n }\\n }\\n }\\n\\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\\n /// actions and then revoking this approval after these actions\\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\\n /// to revoke approvals\\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\\n /// is just an option\\n function mixerVaultManagerPermit(\\n PermitVaultManagerType[] memory paramsPermitVaultManager,\\n PermitType[] memory paramsPermit,\\n ActionType[] calldata actions,\\n bytes[] calldata data\\n ) external payable virtual {\\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\\n for (uint256 i; i < permitVaultManagerLength; ++i) {\\n if (paramsPermitVaultManager[i].approved) {\\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\\n paramsPermitVaultManager[i].owner,\\n address(this),\\n true,\\n paramsPermitVaultManager[i].deadline,\\n paramsPermitVaultManager[i].v,\\n paramsPermitVaultManager[i].r,\\n paramsPermitVaultManager[i].s\\n );\\n } else break;\\n }\\n mixer(paramsPermit, actions, data);\\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\\n // too deep\\n for (uint256 i; i < permitVaultManagerLength; ++i) {\\n if (!paramsPermitVaultManager[i].approved) {\\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\\n paramsPermitVaultManager[i].owner,\\n address(this),\\n false,\\n paramsPermitVaultManager[i].deadline,\\n paramsPermitVaultManager[i].v,\\n paramsPermitVaultManager[i].r,\\n paramsPermitVaultManager[i].s\\n );\\n }\\n }\\n }\\n\\n receive() external payable {}\\n\\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\\n\\n /// @notice Wraps the native token of a chain to its wrapped version\\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\\n /// @dev The amount to wrap is to be specified in the `msg.value`\\n function _wrapNative() internal virtual returns (uint256) {\\n _getNativeWrapper().deposit{ value: msg.value }();\\n return msg.value;\\n }\\n\\n /// @notice Unwraps the wrapped version of a token to the native chain token\\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\\n amount = _getNativeWrapper().balanceOf(address(this));\\n _slippageCheck(amount, minAmountOut);\\n if (amount != 0) {\\n _getNativeWrapper().withdraw(amount);\\n _safeTransferNative(to, amount);\\n }\\n return amount;\\n }\\n\\n /// @notice Internal version of the `claimRewards` function\\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\\n uint256 gaugesLength = liquidityGauges.length;\\n for (uint256 i; i < gaugesLength; ++i) {\\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\\n }\\n }\\n\\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\\n /// @param vaultManager Address of the vault to perform actions on\\n /// @param actionsBorrow Actions type to perform on the vaultManager\\n /// @param dataBorrow Data needed for each actions\\n /// @param to Address to send the funds to\\n /// @param who Swapper address to handle repayments\\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\\n function _angleBorrower(\\n address vaultManager,\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n address to,\\n address who,\\n bytes memory repayData\\n ) internal virtual returns (PaymentData memory paymentData) {\\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\\n }\\n\\n /// @notice Allows to deposit tokens into a gauge\\n /// @param user Address on behalf of which deposits should be made in the gauge\\n /// @param amount Amount to stake\\n /// @param gauge Liquidity gauge to stake in\\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\\n /// @dev The function will revert if the gauge has not already been approved by the contract\\n function _gaugeDeposit(\\n address user,\\n uint256 amount,\\n ILiquidityGauge gauge,\\n bool shouldClaimRewards\\n ) internal virtual {\\n gauge.deposit(amount, user, shouldClaimRewards);\\n }\\n\\n /// @notice Sweeps tokens from the router contract\\n /// @param tokenOut Token to sweep\\n /// @param minAmountOut Minimum amount of tokens to recover\\n /// @param to Address to which tokens should be sent\\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\\n _slippageCheck(balanceToken, minAmountOut);\\n if (balanceToken != 0) {\\n IERC20(tokenOut).safeTransfer(to, balanceToken);\\n }\\n }\\n\\n /// @notice Uses an external swapper\\n /// @param swapper Contracts implementing the logic of the swap\\n /// @param inToken Token used to do the swap\\n /// @param outToken Token wanted\\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\\n /// @param inTokenObtained Amount of `inToken` used for the swap\\n /// @param data Additional info for the specific swapper\\n function _swapper(\\n ISwapper swapper,\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory data\\n ) internal {\\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\\n }\\n\\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\\n /// @param inToken Token used as entrance of the swap\\n /// @param amount Amount of in token to swap\\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\\n function _swapOnUniswapV3(\\n IERC20 inToken,\\n uint256 amount,\\n uint256 minAmountOut,\\n bytes memory path\\n ) internal returns (uint256 amountOut) {\\n // Approve transfer to the `uniswapV3Router`\\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\\n address uniRouter = address(uniswapV3Router);\\n _changeAllowance(IERC20(inToken), uniRouter, type(uint256).max);\\n amountOut = IUniswapV3Router(uniRouter).exactInput(\\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\\n );\\n }\\n\\n /// @notice Swaps an inToken to another token via 1Inch Router\\n /// @param payload Bytes needed for 1Inch router to process the swap\\n /// @dev The `payload` given is expected to be obtained from 1Inch API\\n function _swapOn1Inch(\\n IERC20 inToken,\\n uint256 minAmountOut,\\n bytes memory payload\\n ) internal returns (uint256 amountOut) {\\n // Approve transfer to the `oneInch` address\\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\\n address oneInchRouter = oneInch;\\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\\n //solhint-disable-next-line\\n (bool success, bytes memory result) = oneInchRouter.call(payload);\\n if (!success) _revertBytes(result);\\n\\n amountOut = abi.decode(result, (uint256));\\n _slippageCheck(amountOut, minAmountOut);\\n }\\n\\n /// @notice Mints `shares` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to mint shares from\\n /// @param shares Amount of shares to mint from the contract\\n /// @param to Address to which shares should be sent\\n /// @param maxAmountIn Max amount of assets used to mint\\n /// @return amountIn Amount of assets used to mint by `to`\\n function _mint4626(\\n IERC4626 savingsRate,\\n uint256 shares,\\n address to,\\n uint256 maxAmountIn\\n ) internal returns (uint256 amountIn) {\\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\\n }\\n\\n /// @notice Deposits `amount` to an ERC4626 contract\\n /// @param savingsRate The ERC4626 to deposit assets to\\n /// @param amount Amount of assets to deposit\\n /// @param to Address to which shares should be sent\\n /// @param minSharesOut Minimum amount of shares that `to` should received\\n /// @return sharesOut Amount of shares received by `to`\\n function _deposit4626(\\n IERC4626 savingsRate,\\n uint256 amount,\\n address to,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\\n }\\n\\n /// @notice Withdraws `amount` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to withdraw assets from\\n /// @param amount Amount of assets to withdraw\\n /// @param to Destination of assets\\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\\n /// @return sharesOut Amount of shares burnt\\n function _withdraw4626(\\n IERC4626 savingsRate,\\n uint256 amount,\\n address to,\\n uint256 maxSharesOut\\n ) internal returns (uint256 sharesOut) {\\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\\n }\\n\\n /// @notice Redeems `shares` from an ERC4626 contract\\n /// @param savingsRate ERC4626 to redeem shares from\\n /// @param shares Amount of shares to redeem\\n /// @param to Destination of assets\\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\\n /// @return amountOut Amount of assets received by `to`\\n function _redeem4626(\\n IERC4626 savingsRate,\\n uint256 shares,\\n address to,\\n uint256 minAmountOut\\n ) internal returns (uint256 amountOut) {\\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\\n }\\n\\n /// @notice Allows to perform some specific actions for a chain\\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\\n\\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\\n\\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\\n\\n // ============================ GOVERNANCE FUNCTION ============================\\n\\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\\n modifier onlyGovernorOrGuardian() {\\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\\n _;\\n }\\n\\n /// @notice Sets a new `core` contract\\n function setCore(ICoreBorrow _core) external {\\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\\n core = ICoreBorrow(_core);\\n }\\n\\n /// @notice Changes allowances for different tokens\\n /// @param tokens Addresses of the tokens to allow\\n /// @param spenders Addresses to allow transfer\\n /// @param amounts Amounts to allow\\n function changeAllowance(\\n IERC20[] calldata tokens,\\n address[] calldata spenders,\\n uint256[] calldata amounts\\n ) external onlyGovernorOrGuardian {\\n uint256 tokensLength = tokens.length;\\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\\n for (uint256 i; i < tokensLength; ++i) {\\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\\n }\\n }\\n\\n /// @notice Sets a new router variable\\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\\n if (router == address(0)) revert ZeroAddress();\\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\\n else oneInch = router;\\n }\\n\\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\\n\\n /// @notice Changes allowance of this contract for a given token\\n /// @param token Address of the token to change allowance\\n /// @param spender Address to change the allowance of\\n /// @param amount Amount allowed\\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n // In case `currentAllowance < type(uint256).max / 2` and we want to increase it:\\n // Do nothing (to handle tokens that need reapprovals to 0 and save gas)\\n if (currentAllowance < amount && currentAllowance < type(uint256).max / 2) {\\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\\n } else if (currentAllowance > amount) {\\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\\n }\\n }\\n\\n /// @notice Transfer amount of the native token to the `to` address\\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\\n function _safeTransferNative(address to, uint256 amount) internal {\\n bool success;\\n //solhint-disable-next-line\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n if (!success) revert TransferFailed();\\n }\\n\\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\\n /// the calling address is well approved for all the vaults with which it is interacting\\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\\n /// with a vault are approved for this vault\\n function _parseVaultIDs(\\n ActionBorrowType[] memory actionsBorrow,\\n bytes[] memory dataBorrow,\\n address vaultManager,\\n address collateral\\n ) internal view returns (bytes[] memory) {\\n uint256 actionsBorrowLength = actionsBorrow.length;\\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\\n bool createVaultAction;\\n uint256 lastVaultID;\\n uint256 vaultIDLength;\\n for (uint256 i; i < actionsBorrowLength; ++i) {\\n uint256 vaultID;\\n // If there is a `createVault` action, the router should not worry about looking at\\n // next vaultIDs given equal to 0\\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\\n createVaultAction = true;\\n continue;\\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\\n // as collateral the full contract balance\\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\\n uint256 amount;\\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\\n if (amount == type(uint256).max)\\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\\n continue;\\n // There are different ways depending on the action to find the `vaultID` to parse\\n } else if (\\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\\n ) {\\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\\n vaultID = abi.decode(dataBorrow[i], (uint256));\\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\\n } else continue;\\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\\n // if there has not been any specific action\\n if (vaultID == 0) {\\n if (createVaultAction) {\\n continue;\\n } else {\\n // If we haven't stored the last `vaultID`, we need to fetch it\\n if (lastVaultID == 0) {\\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\\n }\\n vaultID = lastVaultID;\\n }\\n }\\n\\n // Check if this `vaultID` has already been verified\\n for (uint256 j; j < vaultIDLength; ++j) {\\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\\n // If yes, we continue to the next iteration\\n continue;\\n }\\n }\\n // Verify this new `vaultID` and add it to the list\\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\\n revert NotApprovedOrOwner();\\n }\\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\\n vaultIDLength += 1;\\n }\\n return dataBorrow;\\n }\\n\\n /// @notice Checks whether the amount obtained during a swap is not too small\\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\\n if (amount < thresholdAmount) revert TooSmallAmountOut();\\n }\\n\\n /// @notice Internal function used for error handling\\n function _revertBytes(bytes memory errMsg) internal pure {\\n if (errMsg.length != 0) {\\n //solhint-disable-next-line\\n assembly {\\n revert(add(32, errMsg), mload(errMsg))\\n }\\n }\\n revert InvalidReturnMessage();\\n }\\n}\\n\",\"keccak256\":\"0xd0cab24d7769f5bdb284b0c137883f09dc8b49c14c806261d6184c225ce31f37\",\"license\":\"GPL-3.0\"},\"contracts/implementations/celo/AngleRouterCelo.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"../../BaseAngleRouterSidechain.sol\\\";\\n\\n/// @title AngleRouterCelo\\n/// @author Angle Core Team\\n/// @notice Router contract built specifially for Angle use cases on Celo\\ncontract AngleRouterCelo is BaseAngleRouterSidechain {\\n /// @inheritdoc BaseRouter\\n /// @dev There is no wCELO contract on CELO\\n function _getNativeWrapper() internal pure override returns (IWETH9) {\\n return IWETH9(0x0000000000000000000000000000000000000000);\\n }\\n}\\n\",\"keccak256\":\"0x40958e7eea1b2ca3aeb79cc158f0e457368f6e8cdb12e296f4651f3b586af1d3\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IAgTokenMultiChain.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title IAgTokenMultiChain\\n/// @author Angle Core Team\\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\\ninterface IAgTokenMultiChain {\\n function swapIn(\\n address bridgeToken,\\n uint256 amount,\\n address to\\n ) external returns (uint256);\\n\\n function swapOut(\\n address bridgeToken,\\n uint256 amount,\\n address to\\n ) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x535074b018a207b7a518dd6f5b2c7d127e27410dab239a0326177d663fa21e91\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ICoreBorrow.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title ICoreBorrow\\n/// @author Angle Core Team\\n/// @notice Interface for the `CoreBorrow` contract\\n\\ninterface ICoreBorrow {\\n /// @notice Checks whether an address is governor of the Angle Protocol or not\\n /// @param admin Address to check\\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\\n function isGovernor(address admin) external view returns (bool);\\n\\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\\n /// @param admin Address to check\\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\\n /// role by calling the `addGovernor` function\\n function isGovernorOrGuardian(address admin) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x2414539c445977b04bc7e9adac2e5147364994dd74e5d7118b44824956de602c\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ILiquidityGauge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\ninterface ILiquidityGauge {\\n // solhint-disable-next-line\\n function staking_token() external returns (address stakingToken);\\n\\n // solhint-disable-next-line\\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\\n\\n function deposit(\\n uint256 _value,\\n address _addr,\\n // solhint-disable-next-line\\n bool _claim_rewards\\n ) external;\\n\\n // solhint-disable-next-line\\n function claim_rewards(address _addr) external;\\n\\n // solhint-disable-next-line\\n function claim_rewards(address _addr, address _receiver) external;\\n}\\n\",\"keccak256\":\"0x27144c21760603a4e441bb5eecf975ad7f71331ac0ba0a83352b280ccf734756\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ISwapper.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC20.sol\\\";\\n\\n/// @title ISwapper\\n/// @author Angle Core Team\\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\\ninterface ISwapper {\\n function swap(\\n IERC20 inToken,\\n IERC20 outToken,\\n address outTokenRecipient,\\n uint256 outTokenOwed,\\n uint256 inTokenObtained,\\n bytes memory data\\n ) external;\\n}\\n\",\"keccak256\":\"0x506f50d8447c2dc662bd844779cc66a407af07a91210612b956ef47abcc15776\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/ITreasury.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\n/// @title ITreasury\\n/// @author Angle Core Team\\n/// @notice Interface for the `Treasury` contract\\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\\n/// of this module\\ninterface ITreasury {\\n /// @notice Checks whether a given address has well been initialized in this contract\\n /// as a `VaultManager``\\n /// @param _vaultManager Address to check\\n /// @return Whether the address has been initialized or not\\n function isVaultManager(address _vaultManager) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x36bd50a0ab1c46503bb64b8d5777bf3b4fd2da0e2dcfe68c8a9702eb132eb3e2\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IVaultManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"./ITreasury.sol\\\";\\n\\n// ========================= Key Structs and Enums =============================\\n\\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\\n/// to the caller or associated addresses\\nstruct PaymentData {\\n // Stablecoin amount the contract should give\\n uint256 stablecoinAmountToGive;\\n // Stablecoin amount owed to the contract\\n uint256 stablecoinAmountToReceive;\\n // Collateral amount the contract should give\\n uint256 collateralAmountToGive;\\n // Collateral amount owed to the contract\\n uint256 collateralAmountToReceive;\\n}\\n\\n/// @notice Data stored to track someone's loan (or equivalently called position)\\nstruct Vault {\\n // Amount of collateral deposited in the vault\\n uint256 collateralAmount;\\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\\n uint256 normalizedDebt;\\n}\\n\\n/// @notice Actions possible when composing calls to the different entry functions proposed\\nenum ActionBorrowType {\\n createVault,\\n closeVault,\\n addCollateral,\\n removeCollateral,\\n repayDebt,\\n borrow,\\n getDebtIn,\\n permit\\n}\\n\\n// ========================= Interfaces =============================\\n\\n/// @title IVaultManagerFunctions\\n/// @author Angle Core Team\\n/// @notice Interface for the `VaultManager` contract\\n/// @dev This interface only contains functions of the contract which are called by other contracts\\n/// of this module (without getters)\\ninterface IVaultManagerFunctions {\\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\\n /// this function can perform any of the allowed actions in the order of their choice\\n /// @param actions Set of actions to perform\\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\\n /// should either be the `msg.sender` or be approved by the latter\\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\\n /// @return paymentData Struct containing the final transfers executed\\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\\n /// or computations (like `oracleValue`) are done only once\\n function angle(\\n ActionBorrowType[] memory actions,\\n bytes[] memory datas,\\n address from,\\n address to\\n ) external payable returns (PaymentData memory paymentData);\\n\\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\\n /// this function can perform any of the allowed actions in the order of their choice\\n /// @param actions Set of actions to perform\\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\\n /// should either be the `msg.sender` or be approved by the latter\\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\\n /// @param repayData Data to pass to the repayment contract in case of\\n /// @return paymentData Struct containing the final transfers executed\\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\\n /// or computations (like `oracleValue`) are done only once\\n function angle(\\n ActionBorrowType[] memory actions,\\n bytes[] memory datas,\\n address from,\\n address to,\\n address who,\\n bytes memory repayData\\n ) external payable returns (PaymentData memory paymentData);\\n\\n /// @notice Checks whether a given address is approved for a vault or owns this vault\\n /// @param spender Address for which vault ownership should be checked\\n /// @param vaultID ID of the vault to check\\n /// @return Whether the `spender` address owns or is approved for `vaultID`\\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\\n\\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\\n /// @param spender Address to give approval to\\n /// @param approved Whether to give or revoke the approval\\n /// @param deadline Deadline parameter for the signature to be valid\\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\\n function permit(\\n address owner,\\n address spender,\\n bool approved,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n}\\n\\n/// @title IVaultManagerStorage\\n/// @author Angle Core Team\\n/// @notice Interface for the `VaultManager` contract\\n/// @dev This interface contains getters of the contract's public variables used by other contracts\\n/// of this module\\ninterface IVaultManagerStorage {\\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\\n function treasury() external view returns (ITreasury);\\n\\n /// @notice Reference to the collateral handled by this `VaultManager`\\n function collateral() external view returns (IERC20);\\n\\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\\n function vaultIDCount() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x4cf6dc5e5b494165e4d9e524dca5c65f6307e5b005a62287c5e84f1539dc81f1\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/external/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity ^0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Interface for WETH9\\ninterface IWETH9 is IERC20 {\\n /// @notice Deposit ether to get wrapped ether\\n function deposit() external payable;\\n\\n /// @notice Withdraw wrapped ether to get ether\\n function withdraw(uint256) external;\\n}\\n\",\"keccak256\":\"0xb109c1d668416c05f61d6edea2ec7a10b2f8b386fd51a59cc12f929c73d00424\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/external/uniswap/IUniswapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.17;\\n\\nstruct ExactInputParams {\\n bytes path;\\n address recipient;\\n uint256 deadline;\\n uint256 amountIn;\\n uint256 amountOutMinimum;\\n}\\n\\n/// @title Router token swapping functionality\\n/// @notice Functions for swapping tokens via Uniswap V3\\ninterface IUniswapV3Router {\\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\\n/// @title Router for price estimation functionality\\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\\n/// @dev This interface is only used for non critical elements of the protocol\\ninterface IUniswapV2Router {\\n /// @notice Given an input asset amount, returns the maximum output amount of the\\n /// other asset (accounting for fees) given reserves.\\n /// @param path Addresses of the pools used to get prices\\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\\n\\n function swapExactTokensForTokens(\\n uint256 swapAmount,\\n uint256 minExpected,\\n address[] calldata path,\\n address receiver,\\n uint256 swapDeadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x1908fcdc6ff78ad2250f6ccacc7129df464a648cb2a5f376bedbe506d058bb73\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b50600054610100900460ff1615808015620000335750600054600160ff909116105b8062000063575062000050306200013d60201b620018f81760201c565b15801562000063575060005460ff166001145b620000cb5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000ef576000805461ff0019166101001790555b801562000136576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b506200014c565b6001600160a01b03163b151590565b614372806200015c6000396000f3fe6080604052600436106100b55760003560e01c80638000963011610069578063848c48da1161004e578063848c48da146101d9578063b82c4dc1146101ec578063f2f4eb261461020c57600080fd5b8063800096301461019957806383f1d681146101b957600080fd5b80632c76d7a61161009a5780632c76d7a61461013957806342860d4b1461016657806359856d561461018657600080fd5b8063045c08d5146100c15780632026ffa31461011757600080fd5b366100bc57005b600080fd5b3480156100cd57600080fd5b506002546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561012357600080fd5b50610137610132366004613240565b61023f565b005b34801561014557600080fd5b506001546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561017257600080fd5b50610137610181366004613295565b610281565b6101376101943660046134a9565b6104ec565b3480156101a557600080fd5b506101376101b436600461362f565b610888565b3480156101c557600080fd5b506101376101d436600461364c565b610a3a565b6101376101e7366004613681565b610bea565b3480156101f857600080fd5b50610137610207366004613716565b61175a565b34801561021857600080fd5b506000546100ee9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b61027c8383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061191492505050565b505050565b600054610100900460ff16158080156102a15750600054600160ff909116105b806102bb5750303b1580156102bb575060005460ff166001145b61034c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156103aa57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff84166103f7576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff80871662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff90921691909117909155600180548583167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600280549285169290911691909117905580156104e657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b855160005b818110156106b45787818151811061050b5761050b613791565b6020026020010151604001511561069f5787818151811061052e5761052e613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061056757610567613791565b6020026020010151602001513060018c868151811061058857610588613791565b6020026020010151606001518d87815181106105a6576105a6613791565b6020026020010151608001518e88815181106105c4576105c4613791565b602002602001015160a001518f89815181106105e2576105e2613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561068257600080fd5b505af1158015610696573d6000803e3d6000fd5b505050506106a4565b6106b4565b6106ad816137ef565b90506104f1565b506106c28686868686610bea565b60005b8181101561087e578781815181106106df576106df613791565b60200260200101516040015161086e5787818151811061070157610701613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061073a5761073a613791565b6020026020010151602001513060008c868151811061075b5761075b613791565b6020026020010151606001518d878151811061077957610779613791565b6020026020010151608001518e888151811061079757610797613791565b602002602001015160a001518f89815181106107b5576107b5613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561085557600080fd5b505af1158015610869573d6000803e3d6000fd5b505050505b610877816137ef565b90506106c5565b5050505050505050565b6000546040517fe43581b80000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063e43581b890602401602060405180830381865afa1580156108fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091f9190613827565b15806109b657506040517fe43581b800000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff82169063e43581b890602401602060405180830381865afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613827565b155b156109ed576040517fee3675d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff90921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad19190613827565b610b07576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610b54576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060ff16600003610ba5576001805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790555050565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b5050565b845160005b81811015610da257868181518110610c0957610c09613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663d505accf888381518110610c4257610c42613791565b602002602001015160200151308a8581518110610c6157610c61613791565b6020026020010151604001518b8681518110610c7f57610c7f613791565b6020026020010151606001518c8781518110610c9d57610c9d613791565b6020026020010151608001518d8881518110610cbb57610cbb613791565b602002602001015160a001518e8981518110610cd957610cd9613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701526044860193909352606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b158015610d7957600080fd5b505af1158015610d8d573d6000803e3d6000fd5b5050505080610d9b906137ef565b9050610bef565b508360005b8181101561087e576000878783818110610dc357610dc3613791565b9050602002016020810190610dd89190613873565b601a811115610de957610de9613844565b03610f0c576000806000878785818110610e0557610e05613791565b9050602002810190610e179190613894565b810190610e249190613904565b9250925092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8103610ee2576040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190613945565b90505b610f0473ffffffffffffffffffffffffffffffffffffffff84163384846119d1565b50505061174a565b6001878783818110610f2057610f20613791565b9050602002016020810190610f359190613873565b601a811115610f4657610f46613844565b03610f5957610f53611aad565b5061174a565b6002878783818110610f6d57610f6d613791565b9050602002016020810190610f829190613873565b601a811115610f9357610f93613844565b03610fda57600080868684818110610fad57610fad613791565b9050602002810190610fbf9190613894565b810190610fcc919061395e565b91509150610f048282611b16565b6003878783818110610fee57610fee613791565b90506020020160208101906110039190613873565b601a81111561101457611014613844565b0361106057600080600087878581811061103057611030613791565b90506020028101906110429190613894565b81019061104f919061398e565b925092509250610f04838383611c36565b600487878381811061107457611074613791565b90506020020160208101906110899190613873565b601a81111561109a5761109a613844565b036110b057478015610f5357610f533382611cfa565b60058787838181106110c4576110c4613791565b90506020020160208101906110d99190613873565b601a8111156110ea576110ea613844565b036111445760008060008088888681811061110757611107613791565b90506020028101906111199190613894565b8101906111269190613a53565b935093509350935061113a84848484611d3f565b505050505061174a565b600687878381811061115857611158613791565b905060200201602081019061116d9190613873565b601a81111561117e5761117e613844565b036111d357600080600087878581811061119a5761119a613791565b90506020028101906111ac9190613894565b8101906111b99190613ab6565b9250925092506111ca838383611e49565b5050505061174a565b60078787838181106111e7576111e7613791565b90506020020160208101906111fc9190613873565b601a81111561120d5761120d613844565b0361125b5760008086868481811061122757611227613791565b90506020028101906112399190613894565b8101906112469190613b0f565b915091506112548282611914565b505061174a565b600887878381811061126f5761126f613791565b90506020020160208101906112849190613873565b601a81111561129557611295613844565b036112e5576000806000808888868181106112b2576112b2613791565b90506020028101906112c49190613894565b8101906112d19190613bbe565b93509350935093506111ca84848484611f37565b60098787838181106112f9576112f9613791565b905060200201602081019061130e9190613873565b601a81111561131f5761131f613844565b036113c25760008060008060008060008b8b8981811061134157611341613791565b90506020028101906113539190613894565b8101906113609190613d05565b965096509650965096509650965061137a8383888a611fc3565b91506113a787877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6113b586848488888661262e565b505050505050505061174a565b600a8787838181106113d6576113d6613791565b90506020020160208101906113eb9190613873565b601a8111156113fc576113fc613844565b036114665760008060008060008060008b8b8981811061141e5761141e613791565b90506020028101906114309190613894565b81019061143d9190613dd4565b965096509650965096509650965061145a87878787878787612703565b5050505050505061174a565b600b87878381811061147a5761147a613791565b905060200201602081019061148f9190613873565b601a8111156114a0576114a0613844565b0361152a5760008060008060008989878181106114bf576114bf613791565b90506020028101906114d19190613894565b8101906114de9190613e60565b9450945094509450945061151385857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b61151f8484848461279a565b50505050505061174a565b600c87878381811061153e5761153e613791565b90506020020160208101906115539190613873565b601a81111561156457611564613844565b036115e357600080600080600089898781811061158357611583613791565b90506020028101906115959190613894565b8101906115a29190613e60565b945094509450945094506115d785857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b61151f84848484612846565b600d8787838181106115f7576115f7613791565b905060200201602081019061160c9190613873565b601a81111561161d5761161d613844565b0361166d5760008060008088888681811061163a5761163a613791565b905060200281019061164c9190613894565b8101906116599190613ebb565b935093509350935061113a848484846128f0565b600e87878381811061168157611681613791565b90506020020160208101906116969190613873565b601a8111156116a7576116a7613844565b036116f7576000806000808888868181106116c4576116c4613791565b90506020028101906116d69190613894565b8101906116e39190613ebb565b935093509350935061113a84848484612958565b61174a87878381811061170c5761170c613791565b90506020020160208101906117219190613873565b86868481811061173357611733613791565b90506020028101906117459190613894565b6129c3565b611753816137ef565b9050610da7565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa1580156117cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f19190613827565b611827576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806118375750808214155b1561186e576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561087e576118e888888381811061188e5761188e613791565b90506020020160208101906118a3919061362f565b8787848181106118b5576118b5613791565b90506020020160208101906118ca919061362f565b8686858181106118dc576118dc613791565b905060200201356124f0565b6118f1816137ef565b9050611871565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b805160005b818110156104e65782818151811061193357611933613791565b60209081029190910101516040517f84e9bd7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906384e9bd7e90602401600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b50505050806119ca906137ef565b9050611919565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526104e69085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612a52565b60008073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611af757600080fd5b505af1158015611b0b573d6000803e3d6000fd5b505050505034905090565b6000806040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611b85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba99190613945565b9050611bb58184612b5e565b8015611c30576040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101829052600090632e1a7d4d90602401600060405180830381600087803b158015611c0e57600080fd5b505af1158015611c22573d6000803e3d6000fd5b50505050611c308282611cfa565b92915050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc79190613945565b9050611cd38184612b5e565b80156104e6576104e673ffffffffffffffffffffffffffffffffffffffff85168383612b98565b600080600080600085875af190508061027c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60015460009073ffffffffffffffffffffffffffffffffffffffff16611d8686827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6040805160a0810182528481523060208201524281830152606081018790526080810186905290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169163c04b8d5991611dfc9190600401613f71565b6020604051808303816000875af1158015611e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3f9190613945565b9695505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff16611e9085827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6000808273ffffffffffffffffffffffffffffffffffffffff1685604051611eb89190613fd7565b6000604051808303816000865af19150503d8060008114611ef5576040519150601f19603f3d011682016040523d82523d6000602084013e611efa565b606091505b509150915081611f0d57611f0d81612bee565b80806020019051810190611f219190613945565b9350611f2d8487612b5e565b5050509392505050565b6040517f83df67470000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015282151560448301528316906383df674790606401600060405180830381600087803b158015611faf57600080fd5b505af115801561087e573d6000803e3d6000fd5b835160609060008167ffffffffffffffff811115611fe357611fe36132e0565b60405190808252806020026020018201604052801561200c578160200160208202803683370190505b5090506000806000805b858110156124de576000808c838151811061203357612033613791565b6020026020010151600781111561204c5761204c613844565b0361205b5760019450506124ce565b60028c838151811061206f5761206f613791565b6020026020010151600781111561208857612088613844565b0361219f5760008b83815181106120a1576120a1613791565b60200260200101518060200190518101906120bc9190613ff3565b909250905060018101612198576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015612135573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121599190613945565b6040805160208101939093528201526060016040516020818303038152906040528c848151811061218c5761218c613791565b60200260200101819052505b50506124ce565b60038c83815181106121b3576121b3613791565b602002602001015160078111156121cc576121cc613844565b1480612202575060058c83815181106121e7576121e7613791565b6020026020010151600781111561220057612200613844565b145b1561223c578a828151811061221957612219613791565b60200260200101518060200190518101906122349190613ff3565b509050612313565b60018c838151811061225057612250613791565b6020026020010151600781111561226957612269613844565b036122a2578a828151811061228057612280613791565b602002602001015180602001905181019061229b9190613945565b9050612313565b60068c83815181106122b6576122b6613791565b602002602001015160078111156122cf576122cf613844565b0361230d578a82815181106122e6576122e6613791565b60200260200101518060200190518101906123019190614017565b50919250612313915050565b506124ce565b806000036123a457841561232757506124ce565b836000036123a1578973ffffffffffffffffffffffffffffffffffffffff16633c2e941b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561237a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239e9190613945565b93505b50825b60005b838110156123d557818782815181106123c2576123c2613791565b5050506123ce816137ef565b90506123a7565b506040517f430c20810000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff8b169063430c208190604401602060405180830381865afa158015612447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246b9190613827565b6124a1576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808684815181106124b4576124b4613791565b60209081029190910101526124ca600184614055565b9250505b6124d7816137ef565b9050612016565b5088955050505050505b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258a9190613945565b905081811080156125c457506125c160027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff614068565b81105b156125fa576125f5836125d783856140a3565b73ffffffffffffffffffffffffffffffffffffffff87169190612c2f565b6104e6565b818111156104e6576104e68361261084846140a3565b73ffffffffffffffffffffffffffffffffffffffff87169190612d2d565b6126596040518060800160405280600081526020016000815260200160008152602001600081525090565b6040517fde8fc69800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063de8fc698906126b5908990899033908a908a908a9060040161410b565b6080604051808303816000875af11580156126d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f8919061420b565b979650505050505050565b6040517fa5d4096b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063a5d4096b9061275f90899089908990899089908990600401614271565b600060405180830381600087803b15801561277957600080fd5b505af115801561278d573d6000803e3d6000fd5b5050505050505050505050565b6040517f94bf804d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301526000916124e8918491908816906394bf804d906044015b6020604051808303816000875af115801561281a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283e9190613945565b925082612b5e565b6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301526000916124e891871690636e553f65906044015b6020604051808303816000875af11580156128c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e79190613945565b91508183612b5e565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916124e89187169063ba087652906064016128a4565b6040517fb460af940000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916124e89184919088169063b460af94906064016127fb565b601183601a8111156129d7576129d7613844565b03612a10576000808080806129ee868801886142ca565b94509450945094509450612a058585858585612eba565b505050505050505050565b601283601a811115612a2457612a24613844565b0361027c57600080808080612a3b868801886142ca565b94509450945094509450612a058585858585612f76565b6000612ab4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612fdd9092919063ffffffff16565b80519091501561027c5780806020019051810190612ad29190613827565b61027c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610343565b80821015610be6576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261027c9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611a2b565b805115612bfd57805181602001fd5b6040517fee418e3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612ca6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cca9190613945565b612cd49190614055565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506104e69085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc79190613945565b905081811015612e59576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610343565b60405173ffffffffffffffffffffffffffffffffffffffff841660248201528282036044820181905290612eb39086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b5050505050565b6040517f151dd75500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063151dd755906064015b6020604051808303816000875af1158015612f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f609190613945565b9350612f6c8484612b5e565b5091949350505050565b6040517fd44ad63f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063d44ad63f90606401612f1d565b6060612fec8484600085612ff6565b90505b9392505050565b606082471015613088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610343565b73ffffffffffffffffffffffffffffffffffffffff85163b613106576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610343565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161312f9190613fd7565b60006040518083038185875af1925050503d806000811461316c576040519150601f19603f3d011682016040523d82523d6000602084013e613171565b606091505b50915091506126f88282866060831561318b575081612fef565b82511561319b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103439190614329565b73ffffffffffffffffffffffffffffffffffffffff811681146131f157600080fd5b50565b60008083601f84011261320657600080fd5b50813567ffffffffffffffff81111561321e57600080fd5b6020830191508360208260051b850101111561323957600080fd5b9250929050565b60008060006040848603121561325557600080fd5b8335613260816131cf565b9250602084013567ffffffffffffffff81111561327c57600080fd5b613288868287016131f4565b9497909650939450505050565b6000806000606084860312156132aa57600080fd5b83356132b5816131cf565b925060208401356132c5816131cf565b915060408401356132d5816131cf565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160e0810167ffffffffffffffff81118282101715613332576133326132e0565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561337f5761337f6132e0565b604052919050565b600067ffffffffffffffff8211156133a1576133a16132e0565b5060051b60200190565b80151581146131f157600080fd5b803560ff811681146133ca57600080fd5b919050565b600082601f8301126133e057600080fd5b813560206133f56133f083613387565b613338565b82815260e0928302850182019282820191908785111561341457600080fd5b8387015b8581101561349c5781818a0312156134305760008081fd5b61343861330f565b8135613443816131cf565b815281860135613452816131cf565b81870152604082810135908201526060808301359082015260806134778184016133b9565b9082015260a0828101359082015260c080830135908201528452928401928101613418565b5090979650505050505050565b600080600080600080608087890312156134c257600080fd5b863567ffffffffffffffff808211156134da57600080fd5b818901915089601f8301126134ee57600080fd5b813560206134fe6133f083613387565b82815260e09092028401810191818101908d84111561351c57600080fd5b948201945b838610156135b35760e0868f03121561353a5760008081fd5b61354261330f565b863561354d816131cf565b81528684013561355c816131cf565b8185015260408781013561356f816133ab565b9082015260608781013590820152613589608088016133b9565b608082015260a0878101359082015260c08088013590820152825260e09095019490820190613521565b9a50508a0135925050808211156135c957600080fd5b6135d58a838b016133cf565b965060408901359150808211156135eb57600080fd5b6135f78a838b016131f4565b9096509450606089013591508082111561361057600080fd5b5061361d89828a016131f4565b979a9699509497509295939492505050565b60006020828403121561364157600080fd5b8135612fef816131cf565b6000806040838503121561365f57600080fd5b823561366a816131cf565b9150613678602084016133b9565b90509250929050565b60008060008060006060868803121561369957600080fd5b853567ffffffffffffffff808211156136b157600080fd5b6136bd89838a016133cf565b965060208801359150808211156136d357600080fd5b6136df89838a016131f4565b909650945060408801359150808211156136f857600080fd5b50613705888289016131f4565b969995985093965092949392505050565b6000806000806000806060878903121561372f57600080fd5b863567ffffffffffffffff8082111561374757600080fd5b6137538a838b016131f4565b9098509650602089013591508082111561376c57600080fd5b6137788a838b016131f4565b9096509450604089013591508082111561361057600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613820576138206137c0565b5060010190565b60006020828403121561383957600080fd5b8151612fef816133ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561388557600080fd5b8135601b8110612fef57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126138c957600080fd5b83018035915067ffffffffffffffff8211156138e457600080fd5b60200191503681900382131561323957600080fd5b80356133ca816131cf565b60008060006060848603121561391957600080fd5b8335613924816131cf565b92506020840135613934816131cf565b929592945050506040919091013590565b60006020828403121561395757600080fd5b5051919050565b6000806040838503121561397157600080fd5b823591506020830135613983816131cf565b809150509250929050565b6000806000606084860312156139a357600080fd5b83356139ae816131cf565b92506020840135915060408401356132d5816131cf565b600082601f8301126139d657600080fd5b813567ffffffffffffffff8111156139f0576139f06132e0565b613a2160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613338565b818152846020838601011115613a3657600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613a6957600080fd5b8435613a74816131cf565b93506020850135925060408501359150606085013567ffffffffffffffff811115613a9e57600080fd5b613aaa878288016139c5565b91505092959194509250565b600080600060608486031215613acb57600080fd5b8335613ad6816131cf565b925060208401359150604084013567ffffffffffffffff811115613af957600080fd5b613b05868287016139c5565b9150509250925092565b60008060408385031215613b2257600080fd5b8235613b2d816131cf565b915060208381013567ffffffffffffffff811115613b4a57600080fd5b8401601f81018613613b5b57600080fd5b8035613b696133f082613387565b81815260059190911b82018301908381019088831115613b8857600080fd5b928401925b82841015613baf578335613ba0816131cf565b82529284019290840190613b8d565b80955050505050509250929050565b60008060008060808587031215613bd457600080fd5b8435613bdf816131cf565b9350602085013592506040850135613bf6816131cf565b91506060850135613c06816133ab565b939692955090935050565b600082601f830112613c2257600080fd5b81356020613c326133f083613387565b82815260059290921b84018101918181019086841115613c5157600080fd5b8286015b84811015613c7a57803560088110613c6d5760008081fd5b8352918301918301613c55565b509695505050505050565b600082601f830112613c9657600080fd5b81356020613ca66133f083613387565b82815260059290921b84018101918181019086841115613cc557600080fd5b8286015b84811015613c7a57803567ffffffffffffffff811115613ce95760008081fd5b613cf78986838b01016139c5565b845250918301918301613cc9565b600080600080600080600060e0888a031215613d2057600080fd5b8735613d2b816131cf565b96506020880135613d3b816131cf565b9550613d49604089016138f9565b9450613d57606089016138f9565b9350608088013567ffffffffffffffff80821115613d7457600080fd5b613d808b838c01613c11565b945060a08a0135915080821115613d9657600080fd5b613da28b838c01613c85565b935060c08a0135915080821115613db857600080fd5b50613dc58a828b016139c5565b91505092959891949750929550565b600080600080600080600060e0888a031215613def57600080fd5b8735613dfa816131cf565b96506020880135613e0a816131cf565b95506040880135613e1a816131cf565b94506060880135613e2a816131cf565b93506080880135925060a0880135915060c088013567ffffffffffffffff811115613e5457600080fd5b613dc58a828b016139c5565b600080600080600060a08688031215613e7857600080fd5b8535613e83816131cf565b94506020860135613e93816131cf565b9350604086013592506060860135613eaa816131cf565b949793965091946080013592915050565b60008060008060808587031215613ed157600080fd5b8435613edc816131cf565b9350602085013592506040850135613ef3816131cf565b9396929550929360600135925050565b60005b83811015613f1e578181015183820152602001613f06565b50506000910152565b60008151808452613f3f816020860160208601613f03565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a06020840152613f8d60c0840182613f27565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008251613fe9818460208701613f03565b9190910192915050565b6000806040838503121561400657600080fd5b505080516020909101519092909150565b6000806000806080858703121561402d57600080fd5b84519350602085015161403f816131cf565b6040860151606090960151949790965092505050565b80820180821115611c3057611c306137c0565b60008261409e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115611c3057611c306137c0565b600081518084526020808501808196508360051b8101915082860160005b858110156140fe5782840389526140ec848351613f27565b988501989350908401906001016140d4565b5091979650505050505050565b60c0808252875190820181905260009060209060e0840190828b0184805b8381101561417a57825160088110614168577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b85529385019391850191600101614129565b505050508381038285015261418f818a6140b6565b9150506141b4604084018873ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff8616606084015273ffffffffffffffffffffffffffffffffffffffff8516608084015282810360a08401526141fe8185613f27565b9998505050505050505050565b60006080828403121561421d57600080fd5b6040516080810181811067ffffffffffffffff82111715614240576142406132e0565b8060405250825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a08301526142be60c0830184613f27565b98975050505050505050565b600080600080600060a086880312156142e257600080fd5b85356142ed816131cf565b945060208601356142fd816131cf565b93506040860135925060608601359150608086013561431b816131cf565b809150509295509295909350565b602081526000612fef6020830184613f2756fea2646970667358221220613ea70d653995768ec4f8289d1bb4adef56514876bc5211c5819ef51cd59f4264736f6c63430008110033", + "deployedBytecode": "0x6080604052600436106100b55760003560e01c80638000963011610069578063848c48da1161004e578063848c48da146101d9578063b82c4dc1146101ec578063f2f4eb261461020c57600080fd5b8063800096301461019957806383f1d681146101b957600080fd5b80632c76d7a61161009a5780632c76d7a61461013957806342860d4b1461016657806359856d561461018657600080fd5b8063045c08d5146100c15780632026ffa31461011757600080fd5b366100bc57005b600080fd5b3480156100cd57600080fd5b506002546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b34801561012357600080fd5b50610137610132366004613240565b61023f565b005b34801561014557600080fd5b506001546100ee9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561017257600080fd5b50610137610181366004613295565b610281565b6101376101943660046134a9565b6104ec565b3480156101a557600080fd5b506101376101b436600461362f565b610888565b3480156101c557600080fd5b506101376101d436600461364c565b610a3a565b6101376101e7366004613681565b610bea565b3480156101f857600080fd5b50610137610207366004613716565b61175a565b34801561021857600080fd5b506000546100ee9062010000900473ffffffffffffffffffffffffffffffffffffffff1681565b61027c8383838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061191492505050565b505050565b600054610100900460ff16158080156102a15750600054600160ff909116105b806102bb5750303b1580156102bb575060005460ff166001145b61034c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156103aa57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff84166103f7576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff80871662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff90921691909117909155600180548583167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600280549285169290911691909117905580156104e657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b855160005b818110156106b45787818151811061050b5761050b613791565b6020026020010151604001511561069f5787818151811061052e5761052e613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061056757610567613791565b6020026020010151602001513060018c868151811061058857610588613791565b6020026020010151606001518d87815181106105a6576105a6613791565b6020026020010151608001518e88815181106105c4576105c4613791565b602002602001015160a001518f89815181106105e2576105e2613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561068257600080fd5b505af1158015610696573d6000803e3d6000fd5b505050506106a4565b6106b4565b6106ad816137ef565b90506104f1565b506106c28686868686610bea565b60005b8181101561087e578781815181106106df576106df613791565b60200260200101516040015161086e5787818151811061070157610701613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663f51cc7dd89838151811061073a5761073a613791565b6020026020010151602001513060008c868151811061075b5761075b613791565b6020026020010151606001518d878151811061077957610779613791565b6020026020010151608001518e888151811061079757610797613791565b602002602001015160a001518f89815181106107b5576107b5613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701529215156044860152606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b15801561085557600080fd5b505af1158015610869573d6000803e3d6000fd5b505050505b610877816137ef565b90506106c5565b5050505050505050565b6000546040517fe43581b80000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063e43581b890602401602060405180830381865afa1580156108fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091f9190613827565b15806109b657506040517fe43581b800000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff82169063e43581b890602401602060405180830381865afa158015610990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b49190613827565b155b156109ed576040517fee3675d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805473ffffffffffffffffffffffffffffffffffffffff90921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad19190613827565b610b07576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610b54576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060ff16600003610ba5576001805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff00000000000000000000000000000000000000009091161790555050565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84161790555b5050565b845160005b81811015610da257868181518110610c0957610c09613791565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1663d505accf888381518110610c4257610c42613791565b602002602001015160200151308a8581518110610c6157610c61613791565b6020026020010151604001518b8681518110610c7f57610c7f613791565b6020026020010151606001518c8781518110610c9d57610c9d613791565b6020026020010151608001518d8881518110610cbb57610cbb613791565b602002602001015160a001518e8981518110610cd957610cd9613791565b602090810291909101015160c001516040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815273ffffffffffffffffffffffffffffffffffffffff97881660048201529690951660248701526044860193909352606485019190915260ff16608484015260a483015260c482015260e401600060405180830381600087803b158015610d7957600080fd5b505af1158015610d8d573d6000803e3d6000fd5b5050505080610d9b906137ef565b9050610bef565b508360005b8181101561087e576000878783818110610dc357610dc3613791565b9050602002016020810190610dd89190613873565b601a811115610de957610de9613844565b03610f0c576000806000878785818110610e0557610e05613791565b9050602002810190610e179190613894565b810190610e249190613904565b9250925092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8103610ee2576040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190613945565b90505b610f0473ffffffffffffffffffffffffffffffffffffffff84163384846119d1565b50505061174a565b6001878783818110610f2057610f20613791565b9050602002016020810190610f359190613873565b601a811115610f4657610f46613844565b03610f5957610f53611aad565b5061174a565b6002878783818110610f6d57610f6d613791565b9050602002016020810190610f829190613873565b601a811115610f9357610f93613844565b03610fda57600080868684818110610fad57610fad613791565b9050602002810190610fbf9190613894565b810190610fcc919061395e565b91509150610f048282611b16565b6003878783818110610fee57610fee613791565b90506020020160208101906110039190613873565b601a81111561101457611014613844565b0361106057600080600087878581811061103057611030613791565b90506020028101906110429190613894565b81019061104f919061398e565b925092509250610f04838383611c36565b600487878381811061107457611074613791565b90506020020160208101906110899190613873565b601a81111561109a5761109a613844565b036110b057478015610f5357610f533382611cfa565b60058787838181106110c4576110c4613791565b90506020020160208101906110d99190613873565b601a8111156110ea576110ea613844565b036111445760008060008088888681811061110757611107613791565b90506020028101906111199190613894565b8101906111269190613a53565b935093509350935061113a84848484611d3f565b505050505061174a565b600687878381811061115857611158613791565b905060200201602081019061116d9190613873565b601a81111561117e5761117e613844565b036111d357600080600087878581811061119a5761119a613791565b90506020028101906111ac9190613894565b8101906111b99190613ab6565b9250925092506111ca838383611e49565b5050505061174a565b60078787838181106111e7576111e7613791565b90506020020160208101906111fc9190613873565b601a81111561120d5761120d613844565b0361125b5760008086868481811061122757611227613791565b90506020028101906112399190613894565b8101906112469190613b0f565b915091506112548282611914565b505061174a565b600887878381811061126f5761126f613791565b90506020020160208101906112849190613873565b601a81111561129557611295613844565b036112e5576000806000808888868181106112b2576112b2613791565b90506020028101906112c49190613894565b8101906112d19190613bbe565b93509350935093506111ca84848484611f37565b60098787838181106112f9576112f9613791565b905060200201602081019061130e9190613873565b601a81111561131f5761131f613844565b036113c25760008060008060008060008b8b8981811061134157611341613791565b90506020028101906113539190613894565b8101906113609190613d05565b965096509650965096509650965061137a8383888a611fc3565b91506113a787877fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6113b586848488888661262e565b505050505050505061174a565b600a8787838181106113d6576113d6613791565b90506020020160208101906113eb9190613873565b601a8111156113fc576113fc613844565b036114665760008060008060008060008b8b8981811061141e5761141e613791565b90506020028101906114309190613894565b81019061143d9190613dd4565b965096509650965096509650965061145a87878787878787612703565b5050505050505061174a565b600b87878381811061147a5761147a613791565b905060200201602081019061148f9190613873565b601a8111156114a0576114a0613844565b0361152a5760008060008060008989878181106114bf576114bf613791565b90506020028101906114d19190613894565b8101906114de9190613e60565b9450945094509450945061151385857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b61151f8484848461279a565b50505050505061174a565b600c87878381811061153e5761153e613791565b90506020020160208101906115539190613873565b601a81111561156457611564613844565b036115e357600080600080600089898781811061158357611583613791565b90506020028101906115959190613894565b8101906115a29190613e60565b945094509450945094506115d785857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b61151f84848484612846565b600d8787838181106115f7576115f7613791565b905060200201602081019061160c9190613873565b601a81111561161d5761161d613844565b0361166d5760008060008088888681811061163a5761163a613791565b905060200281019061164c9190613894565b8101906116599190613ebb565b935093509350935061113a848484846128f0565b600e87878381811061168157611681613791565b90506020020160208101906116969190613873565b601a8111156116a7576116a7613844565b036116f7576000806000808888868181106116c4576116c4613791565b90506020028101906116d69190613894565b8101906116e39190613ebb565b935093509350935061113a84848484612958565b61174a87878381811061170c5761170c613791565b90506020020160208101906117219190613873565b86868481811061173357611733613791565b90506020028101906117459190613894565b6129c3565b611753816137ef565b9050610da7565b6000546040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201526201000090910473ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa1580156117cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f19190613827565b611827576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806118375750808214155b1561186e576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561087e576118e888888381811061188e5761188e613791565b90506020020160208101906118a3919061362f565b8787848181106118b5576118b5613791565b90506020020160208101906118ca919061362f565b8686858181106118dc576118dc613791565b905060200201356124f0565b6118f1816137ef565b9050611871565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b805160005b818110156104e65782818151811061193357611933613791565b60209081029190910101516040517f84e9bd7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152909116906384e9bd7e90602401600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b50505050806119ca906137ef565b9050611919565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526104e69085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612a52565b60008073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611af757600080fd5b505af1158015611b0b573d6000803e3d6000fd5b505050505034905090565b6000806040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611b85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba99190613945565b9050611bb58184612b5e565b8015611c30576040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101829052600090632e1a7d4d90602401600060405180830381600087803b158015611c0e57600080fd5b505af1158015611c22573d6000803e3d6000fd5b50505050611c308282611cfa565b92915050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc79190613945565b9050611cd38184612b5e565b80156104e6576104e673ffffffffffffffffffffffffffffffffffffffff85168383612b98565b600080600080600085875af190508061027c576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60015460009073ffffffffffffffffffffffffffffffffffffffff16611d8686827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6040805160a0810182528481523060208201524281830152606081018790526080810186905290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169163c04b8d5991611dfc9190600401613f71565b6020604051808303816000875af1158015611e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3f9190613945565b9695505050505050565b60025460009073ffffffffffffffffffffffffffffffffffffffff16611e9085827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6124f0565b6000808273ffffffffffffffffffffffffffffffffffffffff1685604051611eb89190613fd7565b6000604051808303816000865af19150503d8060008114611ef5576040519150601f19603f3d011682016040523d82523d6000602084013e611efa565b606091505b509150915081611f0d57611f0d81612bee565b80806020019051810190611f219190613945565b9350611f2d8487612b5e565b5050509392505050565b6040517f83df67470000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff858116602483015282151560448301528316906383df674790606401600060405180830381600087803b158015611faf57600080fd5b505af115801561087e573d6000803e3d6000fd5b835160609060008167ffffffffffffffff811115611fe357611fe36132e0565b60405190808252806020026020018201604052801561200c578160200160208202803683370190505b5090506000806000805b858110156124de576000808c838151811061203357612033613791565b6020026020010151600781111561204c5761204c613844565b0361205b5760019450506124ce565b60028c838151811061206f5761206f613791565b6020026020010151600781111561208857612088613844565b0361219f5760008b83815181106120a1576120a1613791565b60200260200101518060200190518101906120bc9190613ff3565b909250905060018101612198576040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152829073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015612135573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121599190613945565b6040805160208101939093528201526060016040516020818303038152906040528c848151811061218c5761218c613791565b60200260200101819052505b50506124ce565b60038c83815181106121b3576121b3613791565b602002602001015160078111156121cc576121cc613844565b1480612202575060058c83815181106121e7576121e7613791565b6020026020010151600781111561220057612200613844565b145b1561223c578a828151811061221957612219613791565b60200260200101518060200190518101906122349190613ff3565b509050612313565b60018c838151811061225057612250613791565b6020026020010151600781111561226957612269613844565b036122a2578a828151811061228057612280613791565b602002602001015180602001905181019061229b9190613945565b9050612313565b60068c83815181106122b6576122b6613791565b602002602001015160078111156122cf576122cf613844565b0361230d578a82815181106122e6576122e6613791565b60200260200101518060200190518101906123019190614017565b50919250612313915050565b506124ce565b806000036123a457841561232757506124ce565b836000036123a1578973ffffffffffffffffffffffffffffffffffffffff16633c2e941b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561237a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061239e9190613945565b93505b50825b60005b838110156123d557818782815181106123c2576123c2613791565b5050506123ce816137ef565b90506123a7565b506040517f430c20810000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff8b169063430c208190604401602060405180830381865afa158015612447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246b9190613827565b6124a1576040517fe433766c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808684815181106124b4576124b4613791565b60209081029190910101526124ca600184614055565b9250505b6124d7816137ef565b9050612016565b5088955050505050505b949350505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258a9190613945565b905081811080156125c457506125c160027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff614068565b81105b156125fa576125f5836125d783856140a3565b73ffffffffffffffffffffffffffffffffffffffff87169190612c2f565b6104e6565b818111156104e6576104e68361261084846140a3565b73ffffffffffffffffffffffffffffffffffffffff87169190612d2d565b6126596040518060800160405280600081526020016000815260200160008152602001600081525090565b6040517fde8fc69800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063de8fc698906126b5908990899033908a908a908a9060040161410b565b6080604051808303816000875af11580156126d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f8919061420b565b979650505050505050565b6040517fa5d4096b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063a5d4096b9061275f90899089908990899089908990600401614271565b600060405180830381600087803b15801561277957600080fd5b505af115801561278d573d6000803e3d6000fd5b5050505050505050505050565b6040517f94bf804d0000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301526000916124e8918491908816906394bf804d906044015b6020604051808303816000875af115801561281a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283e9190613945565b925082612b5e565b6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301526000916124e891871690636e553f65906044015b6020604051808303816000875af11580156128c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e79190613945565b91508183612b5e565b6040517fba0876520000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916124e89187169063ba087652906064016128a4565b6040517fb460af940000000000000000000000000000000000000000000000000000000081526004810184905273ffffffffffffffffffffffffffffffffffffffff83811660248301523360448301526000916124e89184919088169063b460af94906064016127fb565b601183601a8111156129d7576129d7613844565b03612a10576000808080806129ee868801886142ca565b94509450945094509450612a058585858585612eba565b505050505050505050565b601283601a811115612a2457612a24613844565b0361027c57600080808080612a3b868801886142ca565b94509450945094509450612a058585858585612f76565b6000612ab4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612fdd9092919063ffffffff16565b80519091501561027c5780806020019051810190612ad29190613827565b61027c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610343565b80821015610be6576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261027c9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611a2b565b805115612bfd57805181602001fd5b6040517fee418e3700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612ca6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cca9190613945565b612cd49190614055565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506104e69085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015612da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc79190613945565b905081811015612e59576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610343565b60405173ffffffffffffffffffffffffffffffffffffffff841660248201528282036044820181905290612eb39086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611a2b565b5050505050565b6040517f151dd75500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063151dd755906064015b6020604051808303816000875af1158015612f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f609190613945565b9350612f6c8484612b5e565b5091949350505050565b6040517fd44ad63f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301526024820185905282811660448301526000919087169063d44ad63f90606401612f1d565b6060612fec8484600085612ff6565b90505b9392505050565b606082471015613088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610343565b73ffffffffffffffffffffffffffffffffffffffff85163b613106576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610343565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161312f9190613fd7565b60006040518083038185875af1925050503d806000811461316c576040519150601f19603f3d011682016040523d82523d6000602084013e613171565b606091505b50915091506126f88282866060831561318b575081612fef565b82511561319b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103439190614329565b73ffffffffffffffffffffffffffffffffffffffff811681146131f157600080fd5b50565b60008083601f84011261320657600080fd5b50813567ffffffffffffffff81111561321e57600080fd5b6020830191508360208260051b850101111561323957600080fd5b9250929050565b60008060006040848603121561325557600080fd5b8335613260816131cf565b9250602084013567ffffffffffffffff81111561327c57600080fd5b613288868287016131f4565b9497909650939450505050565b6000806000606084860312156132aa57600080fd5b83356132b5816131cf565b925060208401356132c5816131cf565b915060408401356132d5816131cf565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160e0810167ffffffffffffffff81118282101715613332576133326132e0565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561337f5761337f6132e0565b604052919050565b600067ffffffffffffffff8211156133a1576133a16132e0565b5060051b60200190565b80151581146131f157600080fd5b803560ff811681146133ca57600080fd5b919050565b600082601f8301126133e057600080fd5b813560206133f56133f083613387565b613338565b82815260e0928302850182019282820191908785111561341457600080fd5b8387015b8581101561349c5781818a0312156134305760008081fd5b61343861330f565b8135613443816131cf565b815281860135613452816131cf565b81870152604082810135908201526060808301359082015260806134778184016133b9565b9082015260a0828101359082015260c080830135908201528452928401928101613418565b5090979650505050505050565b600080600080600080608087890312156134c257600080fd5b863567ffffffffffffffff808211156134da57600080fd5b818901915089601f8301126134ee57600080fd5b813560206134fe6133f083613387565b82815260e09092028401810191818101908d84111561351c57600080fd5b948201945b838610156135b35760e0868f03121561353a5760008081fd5b61354261330f565b863561354d816131cf565b81528684013561355c816131cf565b8185015260408781013561356f816133ab565b9082015260608781013590820152613589608088016133b9565b608082015260a0878101359082015260c08088013590820152825260e09095019490820190613521565b9a50508a0135925050808211156135c957600080fd5b6135d58a838b016133cf565b965060408901359150808211156135eb57600080fd5b6135f78a838b016131f4565b9096509450606089013591508082111561361057600080fd5b5061361d89828a016131f4565b979a9699509497509295939492505050565b60006020828403121561364157600080fd5b8135612fef816131cf565b6000806040838503121561365f57600080fd5b823561366a816131cf565b9150613678602084016133b9565b90509250929050565b60008060008060006060868803121561369957600080fd5b853567ffffffffffffffff808211156136b157600080fd5b6136bd89838a016133cf565b965060208801359150808211156136d357600080fd5b6136df89838a016131f4565b909650945060408801359150808211156136f857600080fd5b50613705888289016131f4565b969995985093965092949392505050565b6000806000806000806060878903121561372f57600080fd5b863567ffffffffffffffff8082111561374757600080fd5b6137538a838b016131f4565b9098509650602089013591508082111561376c57600080fd5b6137788a838b016131f4565b9096509450604089013591508082111561361057600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613820576138206137c0565b5060010190565b60006020828403121561383957600080fd5b8151612fef816133ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561388557600080fd5b8135601b8110612fef57600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126138c957600080fd5b83018035915067ffffffffffffffff8211156138e457600080fd5b60200191503681900382131561323957600080fd5b80356133ca816131cf565b60008060006060848603121561391957600080fd5b8335613924816131cf565b92506020840135613934816131cf565b929592945050506040919091013590565b60006020828403121561395757600080fd5b5051919050565b6000806040838503121561397157600080fd5b823591506020830135613983816131cf565b809150509250929050565b6000806000606084860312156139a357600080fd5b83356139ae816131cf565b92506020840135915060408401356132d5816131cf565b600082601f8301126139d657600080fd5b813567ffffffffffffffff8111156139f0576139f06132e0565b613a2160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613338565b818152846020838601011115613a3657600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613a6957600080fd5b8435613a74816131cf565b93506020850135925060408501359150606085013567ffffffffffffffff811115613a9e57600080fd5b613aaa878288016139c5565b91505092959194509250565b600080600060608486031215613acb57600080fd5b8335613ad6816131cf565b925060208401359150604084013567ffffffffffffffff811115613af957600080fd5b613b05868287016139c5565b9150509250925092565b60008060408385031215613b2257600080fd5b8235613b2d816131cf565b915060208381013567ffffffffffffffff811115613b4a57600080fd5b8401601f81018613613b5b57600080fd5b8035613b696133f082613387565b81815260059190911b82018301908381019088831115613b8857600080fd5b928401925b82841015613baf578335613ba0816131cf565b82529284019290840190613b8d565b80955050505050509250929050565b60008060008060808587031215613bd457600080fd5b8435613bdf816131cf565b9350602085013592506040850135613bf6816131cf565b91506060850135613c06816133ab565b939692955090935050565b600082601f830112613c2257600080fd5b81356020613c326133f083613387565b82815260059290921b84018101918181019086841115613c5157600080fd5b8286015b84811015613c7a57803560088110613c6d5760008081fd5b8352918301918301613c55565b509695505050505050565b600082601f830112613c9657600080fd5b81356020613ca66133f083613387565b82815260059290921b84018101918181019086841115613cc557600080fd5b8286015b84811015613c7a57803567ffffffffffffffff811115613ce95760008081fd5b613cf78986838b01016139c5565b845250918301918301613cc9565b600080600080600080600060e0888a031215613d2057600080fd5b8735613d2b816131cf565b96506020880135613d3b816131cf565b9550613d49604089016138f9565b9450613d57606089016138f9565b9350608088013567ffffffffffffffff80821115613d7457600080fd5b613d808b838c01613c11565b945060a08a0135915080821115613d9657600080fd5b613da28b838c01613c85565b935060c08a0135915080821115613db857600080fd5b50613dc58a828b016139c5565b91505092959891949750929550565b600080600080600080600060e0888a031215613def57600080fd5b8735613dfa816131cf565b96506020880135613e0a816131cf565b95506040880135613e1a816131cf565b94506060880135613e2a816131cf565b93506080880135925060a0880135915060c088013567ffffffffffffffff811115613e5457600080fd5b613dc58a828b016139c5565b600080600080600060a08688031215613e7857600080fd5b8535613e83816131cf565b94506020860135613e93816131cf565b9350604086013592506060860135613eaa816131cf565b949793965091946080013592915050565b60008060008060808587031215613ed157600080fd5b8435613edc816131cf565b9350602085013592506040850135613ef3816131cf565b9396929550929360600135925050565b60005b83811015613f1e578181015183820152602001613f06565b50506000910152565b60008151808452613f3f816020860160208601613f03565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a06020840152613f8d60c0840182613f27565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b60008251613fe9818460208701613f03565b9190910192915050565b6000806040838503121561400657600080fd5b505080516020909101519092909150565b6000806000806080858703121561402d57600080fd5b84519350602085015161403f816131cf565b6040860151606090960151949790965092505050565b80820180821115611c3057611c306137c0565b60008261409e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115611c3057611c306137c0565b600081518084526020808501808196508360051b8101915082860160005b858110156140fe5782840389526140ec848351613f27565b988501989350908401906001016140d4565b5091979650505050505050565b60c0808252875190820181905260009060209060e0840190828b0184805b8381101561417a57825160088110614168577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b85529385019391850191600101614129565b505050508381038285015261418f818a6140b6565b9150506141b4604084018873ffffffffffffffffffffffffffffffffffffffff169052565b73ffffffffffffffffffffffffffffffffffffffff8616606084015273ffffffffffffffffffffffffffffffffffffffff8516608084015282810360a08401526141fe8185613f27565b9998505050505050505050565b60006080828403121561421d57600080fd5b6040516080810181811067ffffffffffffffff82111715614240576142406132e0565b8060405250825181526020830151602082015260408301516040820152606083015160608201528091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a08301526142be60c0830184613f27565b98975050505050505050565b600080600080600060a086880312156142e257600080fd5b85356142ed816131cf565b945060208601356142fd816131cf565b93506040860135925060608601359150608086013561431b816131cf565b809150509295509295909350565b602081526000612fef6020830184613f2756fea2646970667358221220613ea70d653995768ec4f8289d1bb4adef56514876bc5211c5819ef51cd59f4264736f6c63430008110033", + "devdoc": { + "author": "Angle Core Team", + "kind": "dev", + "methods": { + "changeAllowance(address[],address[],uint256[])": { + "params": { + "amounts": "Amounts to allow", + "spenders": "Addresses to allow transfer", + "tokens": "Addresses of the tokens to allow" + } + }, + "claimRewards(address,address[])": { + "details": "If the caller wants to send the rewards to another account it first needs to call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`", + "params": { + "gaugeUser": "Address for which to fetch the rewards from the gauges", + "liquidityGauges": "Gauges to claim on" + } + }, + "mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "details": "With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol does not verify the payload given and cannot check that the swap performed by users actually gives the desired out token: in this case funds may be made accessible to anyone on this contract if the concerned users do not perform a sweep action on these tokens", + "params": { + "actions": "List of actions to be performed by the router (in order of execution)", + "data": "Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters for a given action are stored", + "paramsPermit": "Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract with tokens that do not support permit should approve the contract for these tokens prior to interacting with it" + } + }, + "mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "details": "In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures to revoke approvalsThe router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this is just an option", + "params": { + "paramsPermitVaultManager": "Parameters to sign permit to give allowance to the router for a `VaultManager` contract" + } + } + }, + "title": "AngleRouterCelo", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "changeAllowance(address[],address[],uint256[])": { + "notice": "Changes allowances for different tokens" + }, + "claimRewards(address,address[])": { + "notice": "Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple gauges at once" + }, + "core()": { + "notice": "Core address handling access control" + }, + "initializeRouter(address,address,address)": { + "notice": "Deploys the router contract on a chain" + }, + "mixer((address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "notice": "Allows composable calls to different functions within the protocol" + }, + "mixerVaultManagerPermit((address,address,bool,uint256,uint8,bytes32,bytes32)[],(address,address,uint256,uint256,uint8,bytes32,bytes32)[],uint8[],bytes[])": { + "notice": "Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing actions and then revoking this approval after these actions" + }, + "oneInch()": { + "notice": "Address of 1Inch router used for swaps" + }, + "setCore(address)": { + "notice": "Sets a new `core` contract" + }, + "setRouter(address,uint8)": { + "notice": "Sets a new router variable" + }, + "uniswapV3Router()": { + "notice": "Address of the router used for swaps" + } + }, + "notice": "Router contract built specifially for Angle use cases on Celo", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 6, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 9, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 1544, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "core", + "offset": 2, + "slot": "0", + "type": "t_contract(ICoreBorrow)3549" + }, + { + "astId": 1548, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "uniswapV3Router", + "offset": 0, + "slot": "1", + "type": "t_contract(IUniswapV3Router)3779" + }, + { + "astId": 1551, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "oneInch", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 1555, + "contract": "contracts/implementations/celo/AngleRouterCelo.sol:AngleRouterCelo", + "label": "__gap", + "offset": 0, + "slot": "3", + "type": "t_array(t_uint256)47_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(ICoreBorrow)3549": { + "encoding": "inplace", + "label": "contract ICoreBorrow", + "numberOfBytes": "20" + }, + "t_contract(IUniswapV3Router)3779": { + "encoding": "inplace", + "label": "contract IUniswapV3Router", + "numberOfBytes": "20" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "encoding": "inplace", + "label": "uint8", + "numberOfBytes": "1" + } + } + } +} \ No newline at end of file diff --git a/deployments/celo/solcInputs/382e5f7965175dcf029b988f27abf9db.json b/deployments/celo/solcInputs/382e5f7965175dcf029b988f27abf9db.json new file mode 100644 index 0000000..fc189d4 --- /dev/null +++ b/deployments/celo/solcInputs/382e5f7965175dcf029b988f27abf9db.json @@ -0,0 +1,286 @@ +{ + "language": "Solidity", + "sources": { + "contracts/BaseAngleRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./interfaces/IAgTokenMultiChain.sol\";\nimport \"./BaseRouter.sol\";\n\n/// @title BaseAngleRouterSidechain\n/// @author Angle Core Team\n/// @notice Extension of the `BaseRouter` contract for sidechains\nabstract contract BaseAngleRouterSidechain is BaseRouter {\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\n /// gauges at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @dev If the caller wants to send the rewards to another account it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\n _claimRewards(gaugeUser, liquidityGauges);\n }\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.swapIn) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\n } else if (action == ActionType.swapOut) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\n }\n }\n\n /// @notice Wraps a bridge token to its corresponding canonical version\n function _swapIn(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n\n /// @notice Unwraps a canonical token for one of its bridge version\n function _swapOut(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n}\n" + }, + "contracts/interfaces/IAgTokenMultiChain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IAgTokenMultiChain\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\ninterface IAgTokenMultiChain {\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n}\n" + }, + "contracts/BaseRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n * █ \n ***** ▓▓▓ \n * ▓▓▓▓▓▓▓ \n * ///. ▓▓▓▓▓▓▓▓▓▓▓▓▓ \n ***** //////// ▓▓▓▓▓▓▓ \n * ///////////// ▓▓▓ \n ▓▓ ////////////////// █ ▓▓ \n ▓▓ ▓▓ /////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ //////////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ /////////▓▓▓///////▓▓▓///////// ▓▓ ▓▓ \n ▓▓ ,////////////////////////////////////// ▓▓ ▓▓ \n ▓▓ ////////////////////////////////////////// ▓▓ \n ▓▓ //////////////////////▓▓▓▓///////////////////// \n ,//////////////////////////////////////////////////// \n .////////////////////////////////////////////////////////// \n .//////////////////////////██.,//////////////////////////█ \n .//////////////////////████..,./////////////////////██ \n ...////////////////███████.....,.////////////////███ \n ,.,////////////████████ ........,///////////████ \n .,.,//////█████████ ,.......///////████ \n ,..//████████ ........./████ \n ..,██████ .....,███ \n .██ ,.,█ \n \n \n \n ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ \n ▓▓▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ▓▓▓▓ \n ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓▓▓▓ \n ▓▓▓ ▓▓ ▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ \n*/\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\nimport \"./interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./interfaces/external/IWETH9.sol\";\nimport \"./interfaces/ICoreBorrow.sol\";\nimport \"./interfaces/ILiquidityGauge.sol\";\nimport \"./interfaces/ISwapper.sol\";\nimport \"./interfaces/IVaultManager.sol\";\n\n// ============================== STRUCTS AND ENUM =============================\n\n/// @notice Action types\nenum ActionType {\n transfer,\n wrapNative,\n unwrapNative,\n sweep,\n sweepNative,\n uniswapV3,\n oneInch,\n claimRewards,\n gaugeDeposit,\n borrower,\n swapper,\n mint4626,\n deposit4626,\n redeem4626,\n withdraw4626,\n // Deprecated\n prepareRedeemSavingsRate,\n // Deprecated\n claimRedeemSavingsRate,\n swapIn,\n swapOut,\n claimWeeklyInterest,\n withdraw,\n // Deprecated\n mint,\n deposit,\n // Deprecated\n openPerpetual,\n // Deprecated\n addToPerpetual,\n veANGLEDeposit,\n claimRewardsWithPerps\n}\n\n/// @notice Data needed to get permits\nstruct PermitType {\n address token;\n address owner;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @notice Data to grant permit to the router for a vault\nstruct PermitVaultManagerType {\n address vaultManager;\n address owner;\n bool approved;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @title BaseRouter\n/// @author Angle Core Team\n/// @notice Base contract that Angle router contracts on different chains should override\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\nabstract contract BaseRouter is Initializable {\n using SafeERC20 for IERC20;\n\n // ================================= REFERENCES ================================\n\n /// @notice Core address handling access control\n ICoreBorrow public core;\n /// @notice Address of the router used for swaps\n IUniswapV3Router public uniswapV3Router;\n /// @notice Address of 1Inch router used for swaps\n address public oneInch;\n\n uint256[47] private __gap;\n\n // ============================== EVENTS / ERRORS ==============================\n\n error IncompatibleLengths();\n error InvalidReturnMessage();\n error NotApprovedOrOwner();\n error NotGovernor();\n error NotGovernorOrGuardian();\n error TooSmallAmountOut();\n error TransferFailed();\n error ZeroAddress();\n\n /// @notice Deploys the router contract on a chain\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\n if (_core == address(0)) revert ZeroAddress();\n core = ICoreBorrow(_core);\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\n oneInch = _oneInch;\n }\n\n constructor() initializer {}\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Allows composable calls to different functions within the protocol\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\n /// @param actions List of actions to be performed by the router (in order of execution)\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\n /// for a given action are stored\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\n /// do not perform a sweep action on these tokens\n function mixer(\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) public payable virtual {\n // If all tokens have already been approved, there's no need for this step\n uint256 permitsLength = paramsPermit.length;\n for (uint256 i; i < permitsLength; ++i) {\n IERC20Permit(paramsPermit[i].token).permit(\n paramsPermit[i].owner,\n address(this),\n paramsPermit[i].value,\n paramsPermit[i].deadline,\n paramsPermit[i].v,\n paramsPermit[i].r,\n paramsPermit[i].s\n );\n }\n // Performing actions one after the others\n uint256 actionsLength = actions.length;\n for (uint256 i; i < actionsLength; ++i) {\n if (actions[i] == ActionType.transfer) {\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\n } else if (actions[i] == ActionType.wrapNative) {\n _wrapNative();\n } else if (actions[i] == ActionType.unwrapNative) {\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\n _unwrapNative(minAmountOut, to);\n } else if (actions[i] == ActionType.sweep) {\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\n _sweep(tokenOut, minAmountOut, to);\n } else if (actions[i] == ActionType.sweepNative) {\n uint256 routerBalance = address(this).balance;\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\n } else if (actions[i] == ActionType.uniswapV3) {\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\n data[i],\n (address, uint256, uint256, bytes)\n );\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\n } else if (actions[i] == ActionType.oneInch) {\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\n data[i],\n (address, uint256, bytes)\n );\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\n } else if (actions[i] == ActionType.claimRewards) {\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\n _claimRewards(user, claimLiquidityGauges);\n } else if (actions[i] == ActionType.gaugeDeposit) {\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\n data[i],\n (address, uint256, address, bool)\n );\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\n } else if (actions[i] == ActionType.borrower) {\n (\n address collateral,\n address vaultManager,\n address to,\n address who,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n bytes memory repayData\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\n } else if (actions[i] == ActionType.swapper) {\n (\n ISwapper swapperContract,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory payload\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\n } else if (actions[i] == ActionType.mint4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _mint4626(savingsRate, shares, to, maxAmountIn);\n } else if (actions[i] == ActionType.deposit4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _deposit4626(savingsRate, amount, to, minSharesOut);\n } else if (actions[i] == ActionType.redeem4626) {\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _redeem4626(savingsRate, shares, to, minAmountOut);\n } else if (actions[i] == ActionType.withdraw4626) {\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\n } else {\n _chainSpecificAction(actions[i], data[i]);\n }\n }\n }\n\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\n /// actions and then revoking this approval after these actions\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\n /// to revoke approvals\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\n /// is just an option\n function mixerVaultManagerPermit(\n PermitVaultManagerType[] memory paramsPermitVaultManager,\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) external payable virtual {\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n true,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n } else break;\n }\n mixer(paramsPermit, actions, data);\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\n // too deep\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (!paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n false,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n }\n }\n }\n\n receive() external payable {}\n\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\n\n /// @notice Wraps the native token of a chain to its wrapped version\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\n /// @dev The amount to wrap is to be specified in the `msg.value`\n function _wrapNative() internal virtual returns (uint256) {\n _getNativeWrapper().deposit{ value: msg.value }();\n return msg.value;\n }\n\n /// @notice Unwraps the wrapped version of a token to the native chain token\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\n amount = _getNativeWrapper().balanceOf(address(this));\n _slippageCheck(amount, minAmountOut);\n if (amount != 0) {\n _getNativeWrapper().withdraw(amount);\n _safeTransferNative(to, amount);\n }\n return amount;\n }\n\n /// @notice Internal version of the `claimRewards` function\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\n uint256 gaugesLength = liquidityGauges.length;\n for (uint256 i; i < gaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n }\n\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\n /// @param vaultManager Address of the vault to perform actions on\n /// @param actionsBorrow Actions type to perform on the vaultManager\n /// @param dataBorrow Data needed for each actions\n /// @param to Address to send the funds to\n /// @param who Swapper address to handle repayments\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\n function _angleBorrower(\n address vaultManager,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address to,\n address who,\n bytes memory repayData\n ) internal virtual returns (PaymentData memory paymentData) {\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\n }\n\n /// @notice Allows to deposit tokens into a gauge\n /// @param user Address on behalf of which deposits should be made in the gauge\n /// @param amount Amount to stake\n /// @param gauge Liquidity gauge to stake in\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\n /// @dev The function will revert if the gauge has not already been approved by the contract\n function _gaugeDeposit(\n address user,\n uint256 amount,\n ILiquidityGauge gauge,\n bool shouldClaimRewards\n ) internal virtual {\n gauge.deposit(amount, user, shouldClaimRewards);\n }\n\n /// @notice Sweeps tokens from the router contract\n /// @param tokenOut Token to sweep\n /// @param minAmountOut Minimum amount of tokens to recover\n /// @param to Address to which tokens should be sent\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\n _slippageCheck(balanceToken, minAmountOut);\n if (balanceToken != 0) {\n IERC20(tokenOut).safeTransfer(to, balanceToken);\n }\n }\n\n /// @notice Uses an external swapper\n /// @param swapper Contracts implementing the logic of the swap\n /// @param inToken Token used to do the swap\n /// @param outToken Token wanted\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\n /// @param inTokenObtained Amount of `inToken` used for the swap\n /// @param data Additional info for the specific swapper\n function _swapper(\n ISwapper swapper,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) internal {\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\n }\n\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\n /// @param inToken Token used as entrance of the swap\n /// @param amount Amount of in token to swap\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\n function _swapOnUniswapV3(\n IERC20 inToken,\n uint256 amount,\n uint256 minAmountOut,\n bytes memory path\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `uniswapV3Router`\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address uniRouter = address(uniswapV3Router);\n uint256 currentAllowance = IERC20(inToken).allowance(address(this), uniRouter);\n if (currentAllowance < amount)\n IERC20(inToken).safeIncreaseAllowance(uniRouter, type(uint256).max - currentAllowance);\n amountOut = IUniswapV3Router(uniRouter).exactInput(\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\n );\n }\n\n /// @notice Swaps an inToken to another token via 1Inch Router\n /// @param payload Bytes needed for 1Inch router to process the swap\n /// @dev The `payload` given is expected to be obtained from 1Inch API\n function _swapOn1Inch(\n IERC20 inToken,\n uint256 minAmountOut,\n bytes memory payload\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `oneInch` address\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address oneInchRouter = oneInch;\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\n //solhint-disable-next-line\n (bool success, bytes memory result) = oneInchRouter.call(payload);\n if (!success) _revertBytes(result);\n\n amountOut = abi.decode(result, (uint256));\n _slippageCheck(amountOut, minAmountOut);\n }\n\n /// @notice Mints `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to mint shares from\n /// @param shares Amount of shares to mint from the contract\n /// @param to Address to which shares should be sent\n /// @param maxAmountIn Max amount of assets used to mint\n /// @return amountIn Amount of assets used to mint by `to`\n function _mint4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 maxAmountIn\n ) internal returns (uint256 amountIn) {\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\n }\n\n /// @notice Deposits `amount` to an ERC4626 contract\n /// @param savingsRate The ERC4626 to deposit assets to\n /// @param amount Amount of assets to deposit\n /// @param to Address to which shares should be sent\n /// @param minSharesOut Minimum amount of shares that `to` should received\n /// @return sharesOut Amount of shares received by `to`\n function _deposit4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\n }\n\n /// @notice Withdraws `amount` from an ERC4626 contract\n /// @param savingsRate ERC4626 to withdraw assets from\n /// @param amount Amount of assets to withdraw\n /// @param to Destination of assets\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\n /// @return sharesOut Amount of shares burnt\n function _withdraw4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 maxSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\n }\n\n /// @notice Redeems `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to redeem shares from\n /// @param shares Amount of shares to redeem\n /// @param to Destination of assets\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\n /// @return amountOut Amount of assets received by `to`\n function _redeem4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 minAmountOut\n ) internal returns (uint256 amountOut) {\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\n }\n\n /// @notice Allows to perform some specific actions for a chain\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\n\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\n\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\n\n // ============================ GOVERNANCE FUNCTION ============================\n\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\n modifier onlyGovernorOrGuardian() {\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n _;\n }\n\n /// @notice Sets a new `core` contract\n function setCore(ICoreBorrow _core) external {\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\n core = ICoreBorrow(_core);\n }\n\n /// @notice Changes allowances for different tokens\n /// @param tokens Addresses of the tokens to allow\n /// @param spenders Addresses to allow transfer\n /// @param amounts Amounts to allow\n function changeAllowance(\n IERC20[] calldata tokens,\n address[] calldata spenders,\n uint256[] calldata amounts\n ) external onlyGovernorOrGuardian {\n uint256 tokensLength = tokens.length;\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\n for (uint256 i; i < tokensLength; ++i) {\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\n }\n }\n\n /// @notice Sets a new router variable\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\n if (router == address(0)) revert ZeroAddress();\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\n else oneInch = router;\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Changes allowance of this contract for a given token\n /// @param token Address of the token to change allowance\n /// @param spender Address to change the allowance of\n /// @param amount Amount allowed\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < amount) {\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\n } else if (currentAllowance > amount) {\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\n }\n }\n\n /// @notice Transfer amount of the native token to the `to` address\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\n function _safeTransferNative(address to, uint256 amount) internal {\n bool success;\n //solhint-disable-next-line\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n if (!success) revert TransferFailed();\n }\n\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\n /// the calling address is well approved for all the vaults with which it is interacting\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\n /// with a vault are approved for this vault\n function _parseVaultIDs(\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address vaultManager,\n address collateral\n ) internal view returns (bytes[] memory) {\n uint256 actionsBorrowLength = actionsBorrow.length;\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\n bool createVaultAction;\n uint256 lastVaultID;\n uint256 vaultIDLength;\n for (uint256 i; i < actionsBorrowLength; ++i) {\n uint256 vaultID;\n // If there is a `createVault` action, the router should not worry about looking at\n // next vaultIDs given equal to 0\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\n createVaultAction = true;\n continue;\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\n // as collateral the full contract balance\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\n uint256 amount;\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\n if (amount == type(uint256).max)\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\n continue;\n // There are different ways depending on the action to find the `vaultID` to parse\n } else if (\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\n ) {\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\n vaultID = abi.decode(dataBorrow[i], (uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\n } else continue;\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\n // if there has not been any specific action\n if (vaultID == 0) {\n if (createVaultAction) {\n continue;\n } else {\n // If we haven't stored the last `vaultID`, we need to fetch it\n if (lastVaultID == 0) {\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\n }\n vaultID = lastVaultID;\n }\n }\n\n // Check if this `vaultID` has already been verified\n for (uint256 j; j < vaultIDLength; ++j) {\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\n // If yes, we continue to the next iteration\n continue;\n }\n }\n // Verify this new `vaultID` and add it to the list\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\n revert NotApprovedOrOwner();\n }\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\n vaultIDLength += 1;\n }\n return dataBorrow;\n }\n\n /// @notice Checks whether the amount obtained during a swap is not too small\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\n if (amount < thresholdAmount) revert TooSmallAmountOut();\n }\n\n /// @notice Internal function used for error handling\n function _revertBytes(bytes memory errMsg) internal pure {\n if (errMsg.length != 0) {\n //solhint-disable-next-line\n assembly {\n revert(add(32, errMsg), mload(errMsg))\n }\n }\n revert InvalidReturnMessage();\n }\n}\n" + }, + "contracts/interfaces/external/uniswap/IUniswapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nstruct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n}\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IUniswapV3Router {\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\n/// @title Router for price estimation functionality\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\n/// @dev This interface is only used for non critical elements of the protocol\ninterface IUniswapV2Router {\n /// @notice Given an input asset amount, returns the maximum output amount of the\n /// other asset (accounting for fees) given reserves.\n /// @param path Addresses of the pools used to get prices\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 swapAmount,\n uint256 minExpected,\n address[] calldata path,\n address receiver,\n uint256 swapDeadline\n ) external;\n}\n" + }, + "contracts/interfaces/external/IWETH9.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n /// @notice Deposit ether to get wrapped ether\n function deposit() external payable;\n\n /// @notice Withdraw wrapped ether to get ether\n function withdraw(uint256) external;\n}\n" + }, + "contracts/interfaces/ICoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ICoreBorrow\n/// @author Angle Core Team\n/// @notice Interface for the `CoreBorrow` contract\n\ninterface ICoreBorrow {\n /// @notice Checks whether an address is governor of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\n function isGovernor(address admin) external view returns (bool);\n\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\n /// role by calling the `addGovernor` function\n function isGovernorOrGuardian(address admin) external view returns (bool);\n}\n" + }, + "contracts/interfaces/ILiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface ILiquidityGauge {\n // solhint-disable-next-line\n function staking_token() external returns (address stakingToken);\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external;\n}\n" + }, + "contracts/interfaces/ISwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\n\n/// @title ISwapper\n/// @author Angle Core Team\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\ninterface ISwapper {\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) external;\n}\n" + }, + "contracts/interfaces/IVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./ITreasury.sol\";\n\n// ========================= Key Structs and Enums =============================\n\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\n/// to the caller or associated addresses\nstruct PaymentData {\n // Stablecoin amount the contract should give\n uint256 stablecoinAmountToGive;\n // Stablecoin amount owed to the contract\n uint256 stablecoinAmountToReceive;\n // Collateral amount the contract should give\n uint256 collateralAmountToGive;\n // Collateral amount owed to the contract\n uint256 collateralAmountToReceive;\n}\n\n/// @notice Data stored to track someone's loan (or equivalently called position)\nstruct Vault {\n // Amount of collateral deposited in the vault\n uint256 collateralAmount;\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\n uint256 normalizedDebt;\n}\n\n/// @notice Actions possible when composing calls to the different entry functions proposed\nenum ActionBorrowType {\n createVault,\n closeVault,\n addCollateral,\n removeCollateral,\n repayDebt,\n borrow,\n getDebtIn,\n permit\n}\n\n// ========================= Interfaces =============================\n\n/// @title IVaultManagerFunctions\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface only contains functions of the contract which are called by other contracts\n/// of this module (without getters)\ninterface IVaultManagerFunctions {\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\n /// @param repayData Data to pass to the repayment contract in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approved Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approved,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n\n/// @title IVaultManagerStorage\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface contains getters of the contract's public variables used by other contracts\n/// of this module\ninterface IVaultManagerStorage {\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\n function treasury() external view returns (ITreasury);\n\n /// @notice Reference to the collateral handled by this `VaultManager`\n function collateral() external view returns (IERC20);\n\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\n function vaultIDCount() external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) 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(\n IERC20 token,\n address spender,\n uint256 value\n ) 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 function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\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 if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\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 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.6.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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n" + }, + "contracts/interfaces/ITreasury.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ITreasury\n/// @author Angle Core Team\n/// @notice Interface for the `Treasury` contract\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\n/// of this module\ninterface ITreasury {\n /// @notice Checks whether a given address has well been initialized in this contract\n /// as a `VaultManager``\n /// @param _vaultManager Address to check\n /// @return Whether the address has been initialized or not\n function isVaultManager(address _vaultManager) external view returns (bool);\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-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(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 require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "contracts/mock/MockRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/external/IWETH9.sol\";\n\nimport \"../BaseAngleRouterSidechain.sol\";\n\n/// @title MockRouterSidechain\n/// @author Angle Core Team\n/// @notice Mock contract but built for tests as if to be deployed on Ethereum\ncontract MockRouterSidechain is BaseAngleRouterSidechain {\n IWETH9 public constant WETH = IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n\n function _wrapNative() internal pure override returns (uint256) {\n return 0;\n }\n\n function _unwrapNative(uint256, address) internal pure override returns (uint256 amount) {\n return 0;\n }\n\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return WETH;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\ninterface IERC20PermitUpgradeable {\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 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-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20PermitUpgradeable.sol\";\nimport \"../ERC20Upgradeable.sol\";\nimport \"../../../utils/cryptography/draft-EIP712Upgradeable.sol\";\nimport \"../../../utils/cryptography/ECDSAUpgradeable.sol\";\nimport \"../../../utils/CountersUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 51\n */\nabstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {\n using CountersUpgradeable for CountersUpgradeable.Counter;\n\n mapping(address => CountersUpgradeable.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n function __ERC20Permit_init(string memory name) internal onlyInitializing {\n __EIP712_init_unchained(name, \"1\");\n }\n\n function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSAUpgradeable.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n CountersUpgradeable.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n __ERC20_init_unchained(name_, symbol_);\n }\n\n function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\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 value {ERC20} uses, unless this function is\n * 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[45] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSAUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n *\n * @custom:storage-size 52\n */\nabstract contract EIP712Upgradeable is Initializable {\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n function __EIP712_init(string memory name, string memory version) internal onlyInitializing {\n __EIP712_init_unchained(name, version);\n }\n\n function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n\n /**\n * @dev The hash of the name parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712NameHash() internal virtual view returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /**\n * @dev The hash of the version parameter for the EIP712 domain.\n *\n * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n * are a concern.\n */\n function _EIP712VersionHash() internal virtual view returns (bytes32) {\n return _HASHED_VERSION;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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 IERC20Upgradeable {\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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" + }, + "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\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-upgradeable/utils/StringsUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _HEX_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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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] = _HEX_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" + }, + "contracts/interfaces/IVeANGLE.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @title IVeANGLE\n/// @author Angle Core Team\n/// @notice Interface for the `VeANGLE` contract\ninterface IVeANGLE {\n // solhint-disable-next-line func-name-mixedcase\n function deposit_for(address addr, uint256 amount) external;\n}\n" + }, + "contracts/implementations/mainnet/AngleRouterMainnet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../interfaces/IFeeDistributorFront.sol\";\nimport \"../../interfaces/ISanToken.sol\";\nimport \"../../interfaces/IStableMasterFront.sol\";\nimport \"../../interfaces/IVeANGLE.sol\";\n\nimport \"../../BaseRouter.sol\";\n\n// ============================= STRUCTS AND ENUMS =============================\n\n/// @notice References to the contracts associated to a collateral for a stablecoin\nstruct Pairs {\n IPoolManager poolManager;\n IPerpetualManagerFrontWithClaim perpetualManager;\n ISanToken sanToken;\n ILiquidityGauge gauge;\n}\n\n/// @title AngleRouterMainnet\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Ethereum\n/// @dev Previous implementation with an initialization function can be found here:\n/// https://etherscan.io/address/0x1b2ffdad478d8770ea0e085bdd4e31120736fcd7#code\ncontract AngleRouterMainnet is BaseRouter {\n using SafeERC20 for IERC20;\n\n // =================================== ERRORS ==================================\n\n error InvalidParams();\n\n // ================================== MAPPINGS =================================\n\n /// @notice Maps an agToken to its counterpart `StableMaster`\n mapping(IERC20 => IStableMasterFront) public mapStableMasters;\n /// @notice Maps a `StableMaster` to a mapping of collateral token to its counterpart `PoolManager`\n mapping(IStableMasterFront => mapping(IERC20 => Pairs)) public mapPoolManagers;\n\n uint256[48] private __gapMainnet;\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.claimRewardsWithPerps) {\n (\n address user,\n address[] memory claimLiquidityGauges,\n uint256[] memory claimPerpetualIDs,\n bool addressProcessed,\n address[] memory stablecoins,\n address[] memory collateralsOrPerpetualManagers\n ) = abi.decode(data, (address, address[], uint256[], bool, address[], address[]));\n _claimRewardsWithPerps(\n user,\n claimLiquidityGauges,\n claimPerpetualIDs,\n addressProcessed,\n stablecoins,\n collateralsOrPerpetualManagers\n );\n } else if (action == ActionType.claimWeeklyInterest) {\n (address user, address feeDistributor, bool letInContract) = abi.decode(data, (address, address, bool));\n _claimWeeklyInterest(user, IFeeDistributorFront(feeDistributor), letInContract);\n } else if (action == ActionType.veANGLEDeposit) {\n (address user, uint256 amount) = abi.decode(data, (address, uint256));\n _depositOnLocker(user, amount);\n } else if (action == ActionType.deposit) {\n (\n address user,\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateral,\n address poolManager\n ) = abi.decode(data, (address, uint256, bool, address, address, address));\n _deposit(user, amount, addressProcessed, stablecoinOrStableMaster, collateral, IPoolManager(poolManager));\n } else if (action == ActionType.withdraw) {\n (\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateralOrPoolManager,\n address sanToken\n ) = abi.decode(data, (uint256, bool, address, address, address));\n if (amount == type(uint256).max) amount = IERC20(sanToken).balanceOf(address(this));\n _withdraw(amount, addressProcessed, stablecoinOrStableMaster, collateralOrPoolManager);\n }\n }\n\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\n }\n\n /// @notice Claims rewards for multiple gauges and perpetuals at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @param perpetualIDs Perpetual IDs to claim rewards for\n /// @param addressProcessed Whether `PerpetualManager` list is already accessible in `collateralsOrPerpetualManagers` or if\n /// it should be retrieved from `stablecoins` and `collateralsOrPerpetualManagers`\n /// @param stablecoins Stablecoin contracts linked to the perpetualsIDs. Array of zero addresses if `addressProcessed` is true\n /// @param collateralsOrPerpetualManagers Collateral contracts linked to the perpetualsIDs or `perpetualManager` contracts if\n /// `addressProcessed` is true\n function _claimRewardsWithPerps(\n address gaugeUser,\n address[] memory liquidityGauges,\n uint256[] memory perpetualIDs,\n bool addressProcessed,\n address[] memory stablecoins,\n address[] memory collateralsOrPerpetualManagers\n ) internal {\n uint256 perpetualIDsLength = perpetualIDs.length;\n if (\n perpetualIDsLength != 0 &&\n (stablecoins.length != perpetualIDsLength || collateralsOrPerpetualManagers.length != perpetualIDsLength)\n ) revert IncompatibleLengths();\n\n uint256 liquidityGaugesLength = liquidityGauges.length;\n for (uint256 i; i < liquidityGaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n\n for (uint256 i; i < perpetualIDsLength; ++i) {\n IPerpetualManagerFrontWithClaim perpManager;\n if (addressProcessed) perpManager = IPerpetualManagerFrontWithClaim(collateralsOrPerpetualManagers[i]);\n else {\n (, Pairs memory pairs) = _getInternalContracts(\n IERC20(stablecoins[i]),\n IERC20(collateralsOrPerpetualManagers[i])\n );\n perpManager = pairs.perpetualManager;\n }\n perpManager.getReward(perpetualIDs[i]);\n }\n }\n\n /// @notice Deposits ANGLE on an existing locker\n /// @param user Address to deposit for\n /// @param amount Amount to deposit\n function _depositOnLocker(address user, uint256 amount) internal {\n _getVeANGLE().deposit_for(user, amount);\n }\n\n /// @notice Claims weekly interest distribution and if wanted transfers it to the contract for future use\n /// @param user Address to claim for\n /// @param _feeDistributor Address of the fee distributor to claim to\n /// @dev If `letInContract` (and hence if funds are transferred to the router), you should approve the `angleRouter` to\n /// transfer the token claimed from the `feeDistributor`\n function _claimWeeklyInterest(address user, IFeeDistributorFront _feeDistributor, bool letInContract) internal {\n uint256 amount = _feeDistributor.claim(user);\n if (letInContract) {\n // Fetching info from the `FeeDistributor` to process correctly the withdrawal\n IERC20 token = IERC20(_feeDistributor.token());\n token.safeTransferFrom(msg.sender, address(this), amount);\n }\n }\n\n /// @notice Deposits collateral in the Core Module of the protocol\n /// @param user Address where to send the resulting sanTokens, if this address is the router address then it means\n /// that the intention is to stake the sanTokens obtained in a subsequent `gaugeDeposit` action\n /// @param amount Amount of collateral to deposit\n /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones\n /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false)\n /// or directly the `StableMaster` contract if `addressProcessed`\n /// @param collateral Token to deposit: it can be null if `addressProcessed` is true but in the corresponding\n /// action, the `mixer` needs to get a correct address to compute the amount of tokens to use for the deposit\n /// @param poolManager PoolManager associated to the `collateral` (null if `addressProcessed` is not true)\n function _deposit(\n address user,\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateral,\n IPoolManager poolManager\n ) internal {\n IStableMasterFront stableMaster;\n if (addressProcessed) {\n stableMaster = IStableMasterFront(stablecoinOrStableMaster);\n } else {\n Pairs memory pairs;\n (stableMaster, pairs) = _getInternalContracts(IERC20(stablecoinOrStableMaster), IERC20(collateral));\n poolManager = pairs.poolManager;\n }\n stableMaster.deposit(amount, user, poolManager);\n }\n\n /// @notice Withdraws sanTokens from the protocol\n /// @param amount Amount of sanTokens to withdraw\n /// @param addressProcessed Whether `msg.sender` provided the contracts addresses or the tokens ones\n /// @param stablecoinOrStableMaster Token associated to a `StableMaster` (if `addressProcessed` is false)\n /// or directly the `StableMaster` contract if `addressProcessed`\n /// @param collateralOrPoolManager Collateral to withdraw (if `addressProcessed` is false) or directly\n /// the `PoolManager` contract if `addressProcessed`\n function _withdraw(\n uint256 amount,\n bool addressProcessed,\n address stablecoinOrStableMaster,\n address collateralOrPoolManager\n ) internal {\n IStableMasterFront stableMaster;\n IPoolManager poolManager;\n if (addressProcessed) {\n stableMaster = IStableMasterFront(stablecoinOrStableMaster);\n poolManager = IPoolManager(collateralOrPoolManager);\n } else {\n Pairs memory pairs;\n (stableMaster, pairs) = _getInternalContracts(\n IERC20(stablecoinOrStableMaster),\n IERC20(collateralOrPoolManager)\n );\n poolManager = pairs.poolManager;\n }\n stableMaster.withdraw(amount, address(this), address(this), poolManager);\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Gets Angle contracts associated to a pair (stablecoin, collateral)\n /// @param stablecoin Token associated to a `StableMaster`\n /// @param collateral Collateral to mint/deposit/open perpetual or add collateral from\n /// @dev This function is used to check that the parameters passed by people calling some of the main\n /// router functions are correct\n function _getInternalContracts(\n IERC20 stablecoin,\n IERC20 collateral\n ) internal view returns (IStableMasterFront stableMaster, Pairs memory pairs) {\n stableMaster = mapStableMasters[stablecoin];\n pairs = mapPoolManagers[stableMaster][collateral];\n if (address(stableMaster) == address(0) || address(pairs.poolManager) == address(0)) revert ZeroAddress();\n return (stableMaster, pairs);\n }\n\n /// @notice Returns the veANGLE address\n function _getVeANGLE() internal view virtual returns (IVeANGLE) {\n return IVeANGLE(0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5);\n }\n}\n" + }, + "contracts/interfaces/IFeeDistributorFront.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IFeeDistributorFront\n/// @author Interface for public use of the `FeeDistributor` contract\n/// @dev This interface is used for user related function\ninterface IFeeDistributorFront {\n function token() external returns (address);\n\n function claim(address _addr) external returns (uint256);\n\n function claim(address[20] memory _addr) external returns (bool);\n}\n" + }, + "contracts/interfaces/ISanToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface ISanToken is IERC20Upgradeable {}\n" + }, + "contracts/interfaces/IStableMasterFront.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./IPoolManager.sol\";\nimport \"./ISanToken.sol\";\nimport \"./IPerpetualManager.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n// Struct to handle all the parameters to manage the fees\n// related to a given collateral pool (associated to the stablecoin)\nstruct MintBurnData {\n // Values of the thresholds to compute the minting fees\n // depending on HA hedge (scaled by `BASE_PARAMS`)\n uint64[] xFeeMint;\n // Values of the fees at thresholds (scaled by `BASE_PARAMS`)\n uint64[] yFeeMint;\n // Values of the thresholds to compute the burning fees\n // depending on HA hedge (scaled by `BASE_PARAMS`)\n uint64[] xFeeBurn;\n // Values of the fees at thresholds (scaled by `BASE_PARAMS`)\n uint64[] yFeeBurn;\n // Max proportion of collateral from users that can be covered by HAs\n // It is exactly the same as the parameter of the same name in `PerpetualManager`, whenever one is updated\n // the other changes accordingly\n uint64 targetHAHedge;\n // Minting fees correction set by the `FeeManager` contract: they are going to be multiplied\n // to the value of the fees computed using the hedge curve\n // Scaled by `BASE_PARAMS`\n uint64 bonusMalusMint;\n // Burning fees correction set by the `FeeManager` contract: they are going to be multiplied\n // to the value of the fees computed using the hedge curve\n // Scaled by `BASE_PARAMS`\n uint64 bonusMalusBurn;\n // Parameter used to limit the number of stablecoins that can be issued using the concerned collateral\n uint256 capOnStableMinted;\n}\n\n// Struct to handle all the variables and parameters to handle SLPs in the protocol\n// including the fraction of interests they receive or the fees to be distributed to\n// them\nstruct SLPData {\n // Last timestamp at which the `sanRate` has been updated for SLPs\n uint256 lastBlockUpdated;\n // Fees accumulated from previous blocks and to be distributed to SLPs\n uint256 lockedInterests;\n // Max interests used to update the `sanRate` in a single block\n // Should be in collateral token base\n uint256 maxInterestsDistributed;\n // Amount of fees left aside for SLPs and that will be distributed\n // when the protocol is collateralized back again\n uint256 feesAside;\n // Part of the fees normally going to SLPs that is left aside\n // before the protocol is collateralized back again (depends on collateral ratio)\n // Updated by keepers and scaled by `BASE_PARAMS`\n uint64 slippageFee;\n // Portion of the fees from users minting and burning\n // that goes to SLPs (the rest goes to surplus)\n uint64 feesForSLPs;\n // Slippage factor that's applied to SLPs exiting (depends on collateral ratio)\n // If `slippage = BASE_PARAMS`, SLPs can get nothing, if `slippage = 0` they get their full claim\n // Updated by keepers and scaled by `BASE_PARAMS`\n uint64 slippage;\n // Portion of the interests from lending\n // that goes to SLPs (the rest goes to surplus)\n uint64 interestsForSLPs;\n}\n\n/// @title IStableMasterFront\n/// @author Angle Core Team\n/// @dev Front interface, meaning only user-facing functions\ninterface IStableMasterFront {\n function collateralMap(IPoolManager poolManager)\n external\n view\n returns (\n IERC20 token,\n ISanToken sanToken,\n IPerpetualManagerFrontWithClaim perpetualManager,\n address oracle,\n uint256 stocksUsers,\n uint256 sanRate,\n uint256 collatBase,\n SLPData memory slpData,\n MintBurnData memory feeData\n );\n\n function updateStocksUsers(uint256 amount, address poolManager) external;\n\n function mint(\n uint256 amount,\n address user,\n IPoolManager poolManager,\n uint256 minStableAmount\n ) external;\n\n function burn(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager,\n uint256 minCollatAmount\n ) external;\n\n function deposit(\n uint256 amount,\n address user,\n IPoolManager poolManager\n ) external;\n\n function withdraw(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager\n ) external;\n\n function agToken() external returns (address);\n}\n" + }, + "contracts/interfaces/IPoolManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface IPoolManager {\n function token() external view returns (address);\n}\n" + }, + "contracts/interfaces/IPerpetualManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title Interface of the contract managing perpetuals with claim function\n/// @author Angle Core Team\n/// @dev Front interface with rewards function, meaning only user-facing functions\ninterface IPerpetualManagerFrontWithClaim {\n function getReward(uint256 perpetualID) external;\n\n function addToPerpetual(uint256 perpetualID, uint256 amount) external;\n\n function openPerpetual(\n address owner,\n uint256 amountBrought,\n uint256 amountCommitted,\n uint256 maxOracleRate,\n uint256 minNetMargin\n ) external returns (uint256 perpetualID);\n}\n" + }, + "contracts/mock/MockAngleRouterMainnet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../implementations/mainnet/AngleRouterMainnet.sol\";\n\ncontract MockAngleRouterMainnet is AngleRouterMainnet {\n address public veAngle;\n\n function setAngleAndVeANGLE(address _veAngle) external {\n veAngle = _veAngle;\n }\n\n function _getVeANGLE() internal view override returns (IVeANGLE) {\n return IVeANGLE(veAngle);\n }\n\n function addStableMaster(IERC20 stablecoin, IStableMasterFront stableMaster) external {\n mapStableMasters[stablecoin] = stableMaster;\n }\n\n function addPairs(\n IERC20[] calldata stablecoins,\n IPoolManager[] calldata poolManagers,\n ILiquidityGauge[] calldata liquidityGauges,\n bool[] calldata justLiquidityGauges\n ) external {\n for (uint256 i; i < stablecoins.length; ++i) {\n IStableMasterFront stableMaster = mapStableMasters[stablecoins[i]];\n _addPair(stableMaster, poolManagers[i], liquidityGauges[i], justLiquidityGauges[i]);\n }\n }\n\n function _addPair(\n IStableMasterFront stableMaster,\n IPoolManager poolManager,\n ILiquidityGauge liquidityGauge,\n bool justLiquidityGauge\n ) internal {\n // Fetching the associated `sanToken` and `perpetualManager` from the contract\n (\n IERC20 collateral,\n ISanToken sanToken,\n IPerpetualManagerFrontWithClaim perpetualManager,\n ,\n ,\n ,\n ,\n ,\n\n ) = stableMaster.collateralMap(poolManager);\n // Reverting if the poolManager is not a valid `poolManager`\n if (address(collateral) == address(0)) revert InvalidParams();\n Pairs storage _pairs = mapPoolManagers[stableMaster][collateral];\n if (justLiquidityGauge) {\n // Cannot specify a liquidity gauge if the associated poolManager does not exist\n if (address(_pairs.poolManager) == address(0)) revert ZeroAddress();\n ILiquidityGauge gauge = _pairs.gauge;\n if (address(gauge) != address(0)) {\n _changeAllowance(IERC20(address(sanToken)), address(gauge), 0);\n }\n } else {\n // Checking if the pair has not already been initialized: if yes we need to make the function revert\n // otherwise we could end up with still approved `PoolManager` and `PerpetualManager` contracts\n if (address(_pairs.poolManager) != address(0)) revert InvalidParams();\n _pairs.poolManager = poolManager;\n _pairs.perpetualManager = IPerpetualManagerFrontWithClaim(address(perpetualManager));\n _pairs.sanToken = sanToken;\n _changeAllowance(collateral, address(stableMaster), type(uint256).max);\n _changeAllowance(collateral, address(perpetualManager), type(uint256).max);\n }\n _pairs.gauge = liquidityGauge;\n if (address(liquidityGauge) != address(0)) {\n if (address(sanToken) != liquidityGauge.staking_token()) revert InvalidParams();\n _changeAllowance(IERC20(address(sanToken)), address(liquidityGauge), type(uint256).max);\n }\n }\n}\n\ncontract MockAngleRouterMainnet2 is AngleRouterMainnet {\n function getVeANGLE() external view returns (IVeANGLE) {\n return _getVeANGLE();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private constant _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n /**\n * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.\n * However, to ensure consistency with the upgradeable transpiler, we will continue\n * to reserve a slot.\n * @custom:oz-renamed-from _PERMIT_TYPEHASH\n */\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 value {ERC20} uses, unless this function is\n * 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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 }\n _balances[to] += amount;\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 _balances[account] += amount;\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 }\n _totalSupply -= amount;\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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address owner,\n address spender,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) 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(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/utils/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (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" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_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 // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\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 if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\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] = _HEX_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" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../utils/SafeERC20.sol\";\nimport \"../../../interfaces/IERC4626.sol\";\nimport \"../../../utils/math/Math.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of\n * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626 is ERC20, IERC4626 {\n using Math for uint256;\n\n IERC20Metadata private immutable _asset;\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n constructor(IERC20Metadata asset_) {\n _asset = asset_;\n }\n\n /** @dev See {IERC4262-asset}. */\n function asset() public view virtual override returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4262-totalAssets}. */\n function totalAssets() public view virtual override returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4262-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) {\n return _convertToShares(assets, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) {\n return _convertToAssets(shares, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-maxDeposit}. */\n function maxDeposit(address) public view virtual override returns (uint256) {\n return _isVaultCollateralized() ? type(uint256).max : 0;\n }\n\n /** @dev See {IERC4262-maxMint}. */\n function maxMint(address) public view virtual override returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4262-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual override returns (uint256) {\n return _convertToAssets(balanceOf(owner), Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-maxRedeem}. */\n function maxRedeem(address owner) public view virtual override returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4262-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-previewMint}. */\n function previewMint(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Up);\n }\n\n /** @dev See {IERC4262-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Up);\n }\n\n /** @dev See {IERC4262-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Down);\n }\n\n /** @dev See {IERC4262-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4262-mint}. */\n function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4262-withdraw}. */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4262-redeem}. */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) public virtual override returns (uint256) {\n require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n *\n * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset\n * would represent an infinite amout of shares.\n */\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256 shares) {\n uint256 supply = totalSupply();\n return\n (assets == 0 || supply == 0)\n ? assets.mulDiv(10**decimals(), 10**_asset.decimals(), rounding)\n : assets.mulDiv(supply, totalAssets(), rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256 assets) {\n uint256 supply = totalSupply();\n return\n (supply == 0)\n ? shares.mulDiv(10**_asset.decimals(), 10**decimals(), rounding)\n : shares.mulDiv(totalAssets(), supply, rounding);\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transfered and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transfered, which is a valid state.\n _burn(owner, shares);\n SafeERC20.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _isVaultCollateralized() private view returns (bool) {\n return totalAssets() > 0 || totalSupply() == 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) 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 return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\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(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) 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. It 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 // 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)`.\n // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1;\n uint256 x = a;\n if (x >> 128 > 0) {\n x >>= 128;\n result <<= 64;\n }\n if (x >> 64 > 0) {\n x >>= 64;\n result <<= 32;\n }\n if (x >> 32 > 0) {\n x >>= 32;\n result <<= 16;\n }\n if (x >> 16 > 0) {\n x >>= 16;\n result <<= 8;\n }\n if (x >> 8 > 0) {\n x >>= 8;\n result <<= 4;\n }\n if (x >> 4 > 0) {\n x >>= 4;\n result <<= 2;\n }\n if (x >> 2 > 0) {\n result <<= 1;\n }\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 uint256 result = sqrt(a);\n if (rounding == Rounding.Up && result * result < a) {\n result += 1;\n }\n return result;\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n" + }, + "contracts/external/TransparentUpgradeableProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin. It is fully forked from OpenZeppelin\n * `TransparentUpgradeableProxy`\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n */\n constructor(\n address _logic,\n address admin_,\n bytes memory _data\n ) payable ERC1967Proxy(_logic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _changeAdmin(admin_);\n }\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _getAdmin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address admin_) {\n admin_ = _getAdmin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address implementation_) {\n implementation_ = _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external virtual ifAdmin {\n _changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeToAndCall(newImplementation, data, true);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view virtual returns (address) {\n return _getAdmin();\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _getAdmin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" + }, + "contracts/external/ProxyAdmin.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n * This contract was fully forked from OpenZeppelin `ProxyAdmin`\n */\ncontract ProxyAdmin is Ownable {\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(\n TransparentUpgradeableProxy proxy,\n address implementation,\n bytes memory data\n ) public payable virtual onlyOwner {\n proxy.upgradeToAndCall{ value: msg.value }(implementation, data);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "contracts/mock/MockVeANGLE.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract MockVeANGLE {\n using SafeERC20 for IERC20;\n IERC20 public angle;\n mapping(address => uint256) public counter;\n\n //solhint-disable-next-line\n function deposit_for(address user, uint256 amount) external {\n angle.safeTransferFrom(msg.sender, address(this), amount);\n counter[user] = amount;\n }\n\n function setAngle(address _angle) external {\n angle = IERC20(_angle);\n }\n}\n" + }, + "contracts/mock/MockVaultManagerPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\nimport \"../interfaces/external/IERC1271.sol\";\n\ncontract MockVaultManagerPermit {\n using Address for address;\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n uint256 public vaultIDCount;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n /* solhint-disable var-name-mixedcase */\n bytes32 private _HASHED_NAME;\n bytes32 private _HASHED_VERSION;\n bytes32 private _PERMIT_TYPEHASH;\n /* solhint-enable var-name-mixedcase */\n\n PaymentData public paymentData;\n\n mapping(address => uint256) private _nonces;\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => uint256)) public operatorApprovals;\n mapping(uint256 => mapping(address => bool)) public approved;\n error ExpiredDeadline();\n error InvalidSignature();\n\n constructor(string memory _name) {\n _PERMIT_TYPEHASH = keccak256(\n \"Permit(address owner,address spender,bool approved,uint256 nonce,uint256 deadline)\"\n );\n _HASHED_NAME = keccak256(bytes(_name));\n _HASHED_VERSION = keccak256(bytes(\"1\"));\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function updateVaultIDCount(uint256 _vaultIDCount) external {\n vaultIDCount = _vaultIDCount;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable virtual returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n if (paymentData.stablecoinAmountToReceive >= paymentData.stablecoinAmountToGive) {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToReceive - paymentData.stablecoinAmountToGive;\n if (paymentData.collateralAmountToGive >= paymentData.collateralAmountToReceive) {\n uint256 collateralAmountToGive = paymentData.collateralAmountToGive -\n paymentData.collateralAmountToReceive;\n collateral.safeTransfer(to, collateralAmountToGive);\n stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n } else {\n if (stablecoinPayment > 0) stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n // In this case the collateral amount is necessarily non null\n collateral.safeTransferFrom(\n msg.sender,\n address(this),\n paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive\n );\n }\n } else {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToGive - paymentData.stablecoinAmountToReceive;\n // `stablecoinPayment` is strictly positive in this case\n stablecoin.mint(to, stablecoinPayment);\n if (paymentData.collateralAmountToGive > paymentData.collateralAmountToReceive) {\n collateral.safeTransfer(to, paymentData.collateralAmountToGive - paymentData.collateralAmountToReceive);\n } else {\n uint256 collateralPayment = paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive;\n collateral.safeTransferFrom(msg.sender, address(this), collateralPayment);\n }\n }\n\n return paymentData;\n }\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approvedStatus Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approvedStatus,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n if (block.timestamp > deadline) revert ExpiredDeadline();\n // Additional signature checks performed in the `ECDSAUpgradeable.recover` function\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 || (v != 27 && v != 28))\n revert InvalidSignature();\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n _domainSeparatorV4(),\n keccak256(\n abi.encode(\n _PERMIT_TYPEHASH,\n // 0x3f43a9c6bafb5c7aab4e0cfe239dc5d4c15caf0381c6104188191f78a6640bd8,\n owner,\n spender,\n approvedStatus,\n _useNonce(owner),\n deadline\n )\n )\n )\n );\n if (owner.isContract()) {\n if (IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) != 0x1626ba7e)\n revert InvalidSignature();\n } else {\n address signer = ecrecover(digest, v, r, s);\n if (signer != owner || signer == address(0)) revert InvalidSignature();\n }\n\n _setApprovalForAll(owner, spender, approvedStatus);\n }\n\n function approveSpenderVault(\n address spender,\n uint256 vaultID,\n bool status\n ) external {\n approved[vaultID][spender] = status;\n }\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool) {\n return approved[vaultID][spender];\n }\n\n /// @notice Internal version of the `setApprovalForAll` function\n /// @dev It contains an `approver` field to be used in case someone signs a permit for a particular\n /// address, and this signature is given to the contract by another address (like a router)\n function _setApprovalForAll(\n address approver,\n address operator,\n bool approvedStatus\n ) internal {\n if (operator == approver) revert(\"approval to caller\");\n uint256 approval = approvedStatus ? 1 : 0;\n operatorApprovals[approver][operator] = approval;\n }\n\n /// @notice Returns the current nonce for an `owner` address\n function nonces(address owner) public view returns (uint256) {\n return _nonces[owner];\n }\n\n /// @notice Returns the domain separator for the current chain.\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /// @notice Internal version of the `DOMAIN_SEPARATOR` function\n function _domainSeparatorV4() internal view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n // keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')\n 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,\n _HASHED_NAME,\n _HASHED_VERSION,\n block.chainid,\n address(this)\n )\n );\n }\n\n /// @notice Consumes a nonce for an address: returns the current value and increments it\n function _useNonce(address owner) internal returns (uint256 current) {\n current = _nonces[owner];\n _nonces[owner] = current + 1;\n }\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/interfaces/IAgToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\n/// @title IAgToken\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts\n/// @dev The only functions that are left in the interface are the functions which are used\n/// at another point in the protocol by a different contract\ninterface IAgToken is IERC20Upgradeable {\n // ======================= `StableMaster` functions ============================\n function mint(address account, uint256 amount) external;\n\n function burnFrom(\n uint256 amount,\n address burner,\n address sender\n ) external;\n\n function burnSelf(uint256 amount, address burner) external;\n\n // ========================= External function =================================\n\n function stableMaster() external view returns (address);\n}\n" + }, + "contracts/interfaces/external/IERC1271.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\n/// @title Interface for verifying contract-based account signatures\n/// @notice Interface that verifies provided signature for the data\n/// @dev Interface defined by EIP-1271\ninterface IERC1271 {\n /// @notice Returns whether the provided signature is valid for the provided data\n /// @dev MUST return the bytes4 magic value 0x1626ba7e when function passes.\n /// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5).\n /// MUST allow external calls.\n /// @param hash Hash of the data to be signed\n /// @param signature Signature byte array associated with _data\n /// @return magicValue The bytes4 magic value 0x1626ba7e\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n" + }, + "contracts/mock/MockVaultManagerPermitCollateral.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./MockVaultManagerPermit.sol\";\n\ncontract MockVaultManagerPermitCollateral is MockVaultManagerPermit {\n using Address for address;\n using SafeERC20 for IERC20;\n\n mapping(uint256 => uint256) public collatData;\n\n constructor(string memory _name) MockVaultManagerPermit(_name) {}\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address,\n address,\n address,\n bytes memory\n ) public payable override returns (PaymentData memory) {\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n if (action == ActionBorrowType.addCollateral) {\n (uint256 vaultID, uint256 collateralAmount) = abi.decode(datas[i], (uint256, uint256));\n collatData[vaultID] += collateralAmount;\n collateral.safeTransferFrom(msg.sender, address(this), collateralAmount);\n }\n }\n PaymentData memory returnValue;\n return returnValue;\n }\n\n uint256[49] private __gap;\n}\n" + }, + "contracts/mock/MockVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\n\ncontract MockVaultManager {\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n PaymentData public paymentData;\n\n constructor(address _treasury) {\n treasury = ITreasury(_treasury);\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n if (paymentData.stablecoinAmountToReceive >= paymentData.stablecoinAmountToGive) {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToReceive - paymentData.stablecoinAmountToGive;\n if (paymentData.collateralAmountToGive >= paymentData.collateralAmountToReceive) {\n uint256 collateralAmountToGive = paymentData.collateralAmountToGive -\n paymentData.collateralAmountToReceive;\n collateral.safeTransfer(to, collateralAmountToGive);\n stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n } else {\n if (stablecoinPayment > 0) stablecoin.burnFrom(stablecoinPayment, from, msg.sender);\n // In this case the collateral amount is necessarily non null\n collateral.safeTransferFrom(\n msg.sender,\n address(this),\n paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive\n );\n }\n } else {\n uint256 stablecoinPayment = paymentData.stablecoinAmountToGive - paymentData.stablecoinAmountToReceive;\n // `stablecoinPayment` is strictly positive in this case\n stablecoin.mint(to, stablecoinPayment);\n if (paymentData.collateralAmountToGive > paymentData.collateralAmountToReceive) {\n collateral.safeTransfer(to, paymentData.collateralAmountToGive - paymentData.collateralAmountToReceive);\n } else {\n uint256 collateralPayment = paymentData.collateralAmountToReceive - paymentData.collateralAmountToGive;\n collateral.safeTransferFrom(msg.sender, address(this), collateralPayment);\n }\n }\n\n return paymentData;\n }\n}\n" + }, + "contracts/mock/MockFraudVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/IVaultManager.sol\";\nimport \"../interfaces/ITreasury.sol\";\nimport \"../interfaces/IAgToken.sol\";\n\ncontract MockFraudVaultManager {\n using SafeERC20 for IERC20;\n\n ITreasury public treasury;\n mapping(uint256 => Vault) public vaultData;\n mapping(uint256 => address) public ownerOf;\n uint256 public surplus;\n uint256 public badDebt;\n IAgToken public stablecoin;\n address public oracle = address(this);\n\n address public governor;\n IERC20 public collateral;\n uint256 public oracleValue;\n uint256 public interestAccumulator;\n uint256 public collateralFactor;\n uint256 public totalNormalizedDebt;\n\n PaymentData public paymentData;\n\n constructor(address _treasury) {\n treasury = ITreasury(_treasury);\n }\n\n function accrueInterestToTreasury() external returns (uint256, uint256) {\n // Avoid the function to be view\n if (surplus >= badDebt) {\n stablecoin.mint(msg.sender, surplus - badDebt);\n }\n return (surplus, badDebt);\n }\n\n function read() external view returns (uint256) {\n return oracleValue;\n }\n\n function setParams(\n address _governor,\n address _collateral,\n address _stablecoin,\n uint256 _oracleValue,\n uint256 _interestAccumulator,\n uint256 _collateralFactor,\n uint256 _totalNormalizedDebt\n ) external {\n governor = _governor;\n collateral = IERC20(_collateral);\n stablecoin = IAgToken(_stablecoin);\n interestAccumulator = _interestAccumulator;\n collateralFactor = _collateralFactor;\n totalNormalizedDebt = _totalNormalizedDebt;\n oracleValue = _oracleValue;\n }\n\n function setOwner(uint256 vaultID, address owner) external {\n ownerOf[vaultID] = owner;\n }\n\n function setVaultData(\n uint256 normalizedDebt,\n uint256 collateralAmount,\n uint256 vaultID\n ) external {\n vaultData[vaultID].normalizedDebt = normalizedDebt;\n vaultData[vaultID].collateralAmount = collateralAmount;\n }\n\n function isGovernor(address admin) external view returns (bool) {\n return admin == governor;\n }\n\n function setSurplusBadDebt(\n uint256 _surplus,\n uint256 _badDebt,\n IAgToken _token\n ) external {\n surplus = _surplus;\n badDebt = _badDebt;\n stablecoin = _token;\n }\n\n function setPaymentData(\n uint256 stablecoinAmountToGive,\n uint256 stablecoinAmountToReceive,\n uint256 collateralAmountToGive,\n uint256 collateralAmountToReceive\n ) external {\n paymentData.stablecoinAmountToGive = stablecoinAmountToGive;\n paymentData.stablecoinAmountToReceive = stablecoinAmountToReceive;\n paymentData.collateralAmountToGive = collateralAmountToGive;\n paymentData.collateralAmountToReceive = collateralAmountToReceive;\n }\n\n function getDebtOut(\n uint256 vaultID,\n uint256 amountStablecoins,\n uint256 senderBorrowFee\n ) external {}\n\n function setTreasury(address _treasury) external {\n treasury = ITreasury(_treasury);\n }\n\n function getVaultDebt(uint256 vaultID) external view returns (uint256) {\n vaultID;\n stablecoin;\n return 0;\n }\n\n function createVault(address toVault) external view returns (uint256) {\n toVault;\n stablecoin;\n return 0;\n }\n\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) public payable returns (PaymentData memory) {\n datas;\n from;\n to;\n who;\n repayData;\n for (uint256 i; i < actions.length; ++i) {\n ActionBorrowType action = actions[i];\n action;\n }\n\n return paymentData;\n }\n}\n" + }, + "contracts/mock/MockAgToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../interfaces/IAgToken.sol\";\nimport \"../interfaces/IStableMasterFront.sol\";\nimport \"../interfaces/ITreasury.sol\";\n// OpenZeppelin may update its version of the ERC20PermitUpgradeable token\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title AgToken\n/// @author Angle Core Team\n/// @notice Base contract for agToken, that is to say Angle's stablecoins\n/// @dev This contract is used to create and handle the stablecoins of Angle protocol\n/// @dev It is still possible for any address to burn its agTokens without redeeming collateral in exchange\n/// @dev This contract is the upgraded version of the AgToken that was first deployed on Ethereum mainnet\ncontract MockAgToken is IAgToken, ERC20PermitUpgradeable {\n using SafeERC20 for IERC20;\n // ========================= References to other contracts =====================\n\n /// @notice Reference to the `StableMaster` contract associated to this `AgToken`\n address public override stableMaster;\n uint256 public inFees;\n uint256 public outFees;\n uint256 public constant BASE_PARAMS = 10**9;\n\n // ============================= Constructor ===================================\n\n /// @notice Initializes the `AgToken` contract\n /// @param name_ Name of the token\n /// @param symbol_ Symbol of the token\n /// @param stableMaster_ Reference to the `StableMaster` contract associated to this agToken\n /// @dev By default, agTokens are ERC-20 tokens with 18 decimals\n function initialize(\n string memory name_,\n string memory symbol_,\n address stableMaster_,\n ITreasury _treasury\n ) external initializer {\n __ERC20Permit_init(name_);\n __ERC20_init(name_, symbol_);\n stableMaster = stableMaster_;\n treasury = _treasury;\n isMinter[stableMaster] = true;\n }\n\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor() initializer {}\n\n // ======= Added Parameters and Variables from the first implementation ========\n\n mapping(address => bool) public isMinter;\n /// @notice Reference to the treasury contract which can grant minting rights\n ITreasury public treasury;\n\n // =============================== Added Events ================================\n\n event TreasuryUpdated(address indexed _treasury);\n event MinterToggled(address indexed minter);\n\n // =============================== Modifiers ===================================\n\n /// @notice Checks to see if it is the `StableMaster` calling this contract\n /// @dev There is no Access Control here, because it can be handled cheaply through this modifier\n modifier onlyTreasury() {\n require(msg.sender == address(treasury), \"1\");\n _;\n }\n\n /// @notice Checks whether the sender has the minting right\n modifier onlyMinter() {\n require(isMinter[msg.sender], \"35\");\n _;\n }\n\n // ========================= External Functions ================================\n // The following functions allow anyone to burn stablecoins without redeeming collateral\n // in exchange for that\n\n /// @notice Destroys `amount` token from the caller without giving collateral back\n /// @param amount Amount to burn\n /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will\n /// need to be updated\n /// @dev When calling this function, people should specify the `poolManager` for which they want to decrease\n /// the `stocksUsers`: this a way for the protocol to maintain healthy accounting variables\n function burnNoRedeem(uint256 amount, address poolManager) external {\n _burn(msg.sender, amount);\n IStableMasterFront(stableMaster).updateStocksUsers(amount, poolManager);\n }\n\n /// @notice Burns `amount` of agToken on behalf of another account without redeeming collateral back\n /// @param account Account to burn on behalf of\n /// @param amount Amount to burn\n /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will need to be updated\n function burnFromNoRedeem(\n address account,\n uint256 amount,\n address poolManager\n ) external {\n _burnFromNoRedeem(amount, account, msg.sender);\n IStableMasterFront(stableMaster).updateStocksUsers(amount, poolManager);\n }\n\n /// @notice Allows anyone to burn agToken without redeeming collateral back\n /// @param amount Amount of stablecoins to burn\n /// @dev This function can typically be called if there is a settlement mechanism to burn stablecoins\n function burnStablecoin(uint256 amount) external {\n _burn(msg.sender, amount);\n }\n\n // ======================= Minter Role Only Functions ==========================\n\n /// @inheritdoc IAgToken\n function burnSelf(uint256 amount, address burner) external override {\n _burn(burner, amount);\n }\n\n /// @inheritdoc IAgToken\n function burnFrom(\n uint256 amount,\n address burner,\n address sender\n ) external override onlyMinter {\n _burnFromNoRedeem(amount, burner, sender);\n }\n\n /// @inheritdoc IAgToken\n function mint(address account, uint256 amount) external override {\n _mint(account, amount);\n }\n\n // ======================= Treasury Only Functions =============================\n\n function addMinter(address minter) external {\n isMinter[minter] = true;\n emit MinterToggled(minter);\n }\n\n function removeMinter(address minter) external {\n // The `treasury` contract cannot remove the `stableMaster`\n require((msg.sender == address(treasury) && minter != stableMaster) || msg.sender == minter, \"36\");\n isMinter[minter] = false;\n emit MinterToggled(minter);\n }\n\n function setTreasury(address _treasury) external onlyTreasury {\n treasury = ITreasury(_treasury);\n emit TreasuryUpdated(_treasury);\n }\n\n // ============================ Internal Function ==============================\n\n /// @notice Internal version of the function `burnFromNoRedeem`\n /// @param amount Amount to burn\n /// @dev It is at the level of this function that allowance checks are performed\n function _burnFromNoRedeem(\n uint256 amount,\n address burner,\n address sender\n ) internal {\n if (burner != sender) {\n uint256 currentAllowance = allowance(burner, sender);\n require(currentAllowance >= amount, \"23\");\n _approve(burner, sender, currentAllowance - amount);\n }\n _burn(burner, amount);\n }\n\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256) {\n IERC20(bridgeToken).safeTransferFrom(msg.sender, address(this), amount);\n uint256 canonicalOut = (amount * (BASE_PARAMS - inFees)) / BASE_PARAMS;\n _mint(to, canonicalOut);\n return canonicalOut;\n }\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256) {\n _burn(msg.sender, amount);\n uint256 bridgeOut = (amount * (BASE_PARAMS - outFees)) / BASE_PARAMS;\n\n IERC20(bridgeToken).safeTransfer(to, bridgeOut);\n return bridgeOut;\n }\n\n function setFees(uint256 _inFees, uint256 _outFees) external {\n inFees = _inFees;\n outFees = _outFees;\n }\n}\n" + }, + "contracts/mock/MockStableMaster.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\nimport \"../interfaces/ISanToken.sol\";\nimport \"../interfaces/IPerpetualManager.sol\";\nimport \"../interfaces/IStableMasterFront.sol\";\n\nimport \"./MockAgToken.sol\";\n\ncontract MockStableMaster is IStableMasterFront {\n using SafeERC20 for IERC20;\n address public agToken;\n\n constructor(address _agToken) {\n agToken = _agToken;\n }\n\n struct Collateral {\n IERC20 collateral;\n ISanToken sanToken;\n IPerpetualManagerFrontWithClaim perpetualManager;\n address oracle;\n uint256 stocksUsers;\n uint256 sanRate;\n uint256 collatBase;\n SLPData slpData;\n MintBurnData feeData;\n }\n\n mapping(IPoolManager => Collateral) public collateralMap;\n\n function addCollateral(\n address poolManager,\n address collateral,\n address sanToken,\n address perpetualManager\n ) external {\n Collateral memory collat;\n collat.collateral = IERC20(collateral);\n collat.sanToken = ISanToken(sanToken);\n collat.perpetualManager = IPerpetualManagerFrontWithClaim(perpetualManager);\n collateralMap[IPoolManager(poolManager)] = collat;\n }\n\n function mint(\n uint256 amount,\n address user,\n IPoolManager poolManager,\n uint256\n ) external {\n collateralMap[poolManager].collateral.safeTransferFrom(msg.sender, address(this), amount);\n MockAgToken(agToken).mint(user, amount);\n }\n\n function burn(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager,\n uint256\n ) external {\n MockAgToken(agToken).burnSelf(amount, burner);\n collateralMap[poolManager].collateral.safeTransfer(dest, amount);\n }\n\n function deposit(\n uint256 amount,\n address user,\n IPoolManager poolManager\n ) external {\n collateralMap[poolManager].collateral.safeTransferFrom(msg.sender, address(this), amount);\n IERC20(address(collateralMap[poolManager].sanToken)).safeTransfer(user, amount);\n }\n\n function withdraw(\n uint256 amount,\n address burner,\n address dest,\n IPoolManager poolManager\n ) external {\n IERC20(address(collateralMap[poolManager].sanToken)).safeTransferFrom(burner, address(this), amount);\n collateralMap[poolManager].collateral.safeTransfer(dest, amount);\n }\n\n function updateStocksUsers(uint256, address) external {}\n}\n" + }, + "contracts/mock/MockPerpetualManager.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../interfaces/ISanToken.sol\";\nimport \"../interfaces/IPerpetualManager.sol\";\n\ncontract MockPerpetualManager {\n using SafeERC20 for IERC20;\n\n IERC20 public rewardToken;\n IERC20 public token;\n uint256 public counter;\n mapping(uint256 => uint256) public perps;\n mapping(uint256 => uint256) public claims;\n\n function setRewardToken(address _rewardToken) external {\n rewardToken = IERC20(_rewardToken);\n }\n\n function setToken(address _token) external {\n token = IERC20(_token);\n }\n\n function getReward(uint256 perpetualID) external {\n claims[perpetualID] += 1;\n }\n\n function addToPerpetual(uint256 perpetualID, uint256 amount) external {\n token.safeTransferFrom(msg.sender, address(this), amount);\n perps[perpetualID] += amount;\n }\n\n function openPerpetual(\n address,\n uint256 amountBrought,\n uint256,\n uint256,\n uint256\n ) external returns (uint256 perpetualID) {\n token.safeTransferFrom(msg.sender, address(this), amountBrought);\n perpetualID = counter;\n counter += 1;\n perps[perpetualID] = amountBrought;\n }\n}\n" + }, + "contracts/mock/MockSwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract MockSwapper {\n using SafeERC20 for IERC20;\n\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory\n ) external {\n inToken.safeTransferFrom(msg.sender, address(this), inTokenObtained);\n outToken.safeTransfer(outTokenRecipient, outTokenOwed);\n }\n}\n" + }, + "contracts/mock/MockLiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../interfaces/ILiquidityGauge.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @notice MockLiquidityGauge contract\ncontract MockLiquidityGauge is ILiquidityGauge {\n using SafeERC20 for IERC20;\n\n uint256 public factor = 10**18;\n\n IERC20 public token;\n mapping(address => uint256) public counter;\n mapping(address => uint256) public counter2;\n\n constructor(address _token) {\n token = IERC20(_token);\n }\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external override {\n IERC20(_rewardToken).transferFrom(msg.sender, address(this), _amount);\n }\n\n function setFactor(uint256 _factor) external {\n factor = _factor;\n }\n\n // solhint-disable-next-line\n function staking_token() external view override returns (address stakingToken) {\n return address(token);\n }\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external override {\n _value;\n _addr;\n _claim_rewards;\n counter2[_addr] += 1;\n return;\n }\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external override {\n _addr;\n counter[_addr] += 1;\n return;\n }\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external pure override {\n _addr;\n _receiver;\n return;\n }\n}\n" + }, + "contracts/mock/MockFeeDistributor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ncontract MockFeeDistributor {\n using SafeERC20 for IERC20;\n\n address public token;\n\n constructor() {}\n\n function claim(address user) external returns (uint256 amount) {\n amount = IERC20(token).balanceOf(address(this));\n IERC20(token).safeTransfer(user, amount);\n }\n\n function setToken(address _token) external {\n token = _token;\n }\n}\n" + }, + "contracts/interfaces/external/lido/IWStETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title IWStETH\n/// @author Angle Core Team\n/// @notice Interface for the `WStETH` contract\n/// @dev This interface only contains functions of the `WStETH` which are called by other contracts\n/// of this module\ninterface IWStETH is IERC20 {\n function stETH() external returns (address);\n\n function wrap(uint256 _stETHAmount) external returns (uint256);\n\n function unwrap(uint256 _wstETHAmount) external returns (uint256);\n}\n" + }, + "contracts/interfaces/external/lido/ISteth.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IStETH is IERC20 {\n event Submitted(address sender, uint256 amount, address referral);\n\n function submit(address) external payable returns (uint256);\n\n function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256);\n}\n" + }, + "contracts/mock/MockUniswapV3Router.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"../interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./MockTokenPermit.sol\";\n\n// @notice mock contract to swap token\ncontract MockUniswapV3Router is IUniswapV3Router {\n uint256 public exchangeRate = 1 ether;\n IERC20Metadata public tokenA;\n IERC20Metadata public tokenB;\n uint256 public decimalsA;\n uint256 public decimalsB;\n\n constructor(IERC20Metadata _tokenA, IERC20Metadata _tokenB) {\n tokenA = _tokenA;\n tokenB = _tokenB;\n decimalsA = _tokenA.decimals();\n decimalsB = _tokenB.decimals();\n MockTokenPermit(address(tokenB)).mint(address(this), type(uint256).max / 1000);\n }\n\n function exactInput(ExactInputParams calldata params) external payable override returns (uint256 amountOut) {\n tokenA.transferFrom(msg.sender, address(this), params.amountIn);\n amountOut = (((params.amountIn * exchangeRate) / 1 ether) * 10**decimalsB) / 10**decimalsA;\n tokenB.transfer(msg.sender, amountOut);\n }\n\n function updateExchangeRate(uint256 newExchangeRate) external {\n exchangeRate = newExchangeRate;\n }\n}\n" + }, + "contracts/mock/MockTokenPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\n\ncontract MockTokenPermit is ERC20Permit {\n event Minting(address indexed _to, address indexed _minter, uint256 _amount);\n\n event Burning(address indexed _from, address indexed _burner, uint256 _amount);\n\n uint8 internal _decimal;\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) ERC20Permit(name_) ERC20(name_, symbol_) {\n _decimal = decimal_;\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 function decimals() public view override returns (uint8) {\n return _decimal;\n }\n\n /// @notice allow to mint\n /// @param account the account to mint to\n /// @param amount the amount to mint\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n emit Minting(account, msg.sender, amount);\n }\n\n /// @notice allow to burn\n /// @param account the account to burn from\n /// @param amount the amount of agToken to burn from caller\n function burn(address account, uint256 amount) public {\n _burn(account, amount);\n emit Burning(account, msg.sender, amount);\n }\n\n function setAllowance(address from, address to) public {\n _approve(from, to, type(uint256).max);\n }\n}\n" + }, + "contracts/mock/Mock1Inch.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./MockTokenPermit.sol\";\n\nstruct SwapDescription {\n IERC20 srcToken;\n IERC20 dstToken;\n address payable srcReceiver;\n address payable dstReceiver;\n uint256 amount;\n uint256 minReturnAmount;\n uint256 flags;\n bytes permit;\n}\n\n// File contracts/interfaces/IAggregationExecutor.sol\n/// @title Interface for making arbitrary calls during swap\ninterface IAggregationExecutor {\n /// @notice Make calls on `msgSender` with specified data\n function callBytes(address msgSender, bytes calldata data) external payable; // 0x2636f7f8\n}\n\n// @notice mock contract to swap token\ncontract Mock1Inch {\n uint256 public exchangeRate = 1 ether;\n IERC20Metadata public tokenA;\n IERC20Metadata public tokenB;\n uint256 public decimalsA;\n uint256 public decimalsB;\n\n constructor(IERC20Metadata _tokenA, IERC20Metadata _tokenB) {\n tokenA = _tokenA;\n tokenB = _tokenB;\n decimalsA = _tokenA.decimals();\n decimalsB = _tokenB.decimals();\n MockTokenPermit(address(tokenB)).mint(address(this), type(uint256).max / 1000);\n }\n\n function swap(\n IAggregationExecutor caller,\n SwapDescription calldata desc,\n bytes calldata data\n )\n external\n payable\n returns (\n uint256 returnAmount,\n uint256 spentAmount,\n uint256 gasLeft\n )\n {\n caller;\n data;\n spentAmount;\n gasLeft;\n tokenA.transferFrom(msg.sender, address(this), desc.amount);\n returnAmount = (((desc.amount * exchangeRate) / 1 ether) * 10**decimalsB) / 10**decimalsA;\n tokenB.transfer(msg.sender, returnAmount);\n }\n\n function unsupportedSwap() external payable returns (address returnAmount) {\n return address(this);\n }\n\n function revertingSwap() external payable {\n revert(\"wrong swap\");\n }\n\n function updateExchangeRate(uint256 newExchangeRate) external {\n exchangeRate = newExchangeRate;\n }\n}\n" + }, + "contracts/mock/MockSavingsRate.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\n\ncontract MockSavingsRate is ERC4626 {\n constructor(IERC20Metadata asset_) ERC20(\"savingsRate\", \"sr\") ERC4626(asset_) {}\n}\n" + }, + "contracts/mock/MockERC4626.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\n\ncontract MockERC4626 is ERC4626 {\n constructor(\n IERC20Metadata asset_,\n string memory name_,\n string memory symbol_\n ) ERC4626(asset_) ERC20(name_, symbol_) {}\n}\n" + }, + "contracts/mock/MockToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MockToken is ERC20 {\n event Minting(address indexed _to, address indexed _minter, uint256 _amount);\n\n event Burning(address indexed _from, address indexed _burner, uint256 _amount);\n\n uint8 internal _decimal;\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) ERC20(name_, symbol_) {\n _decimal = decimal_;\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 function decimals() public view override returns (uint8) {\n return _decimal;\n }\n\n /// @notice allow to mint\n /// @param account the account to mint to\n /// @param amount the amount to mint\n function mint(address account, uint256 amount) external {\n _mint(account, amount);\n emit Minting(account, msg.sender, amount);\n }\n\n /// @notice allow to burn\n /// @param account the account to burn from\n /// @param amount the amount of agToken to burn from caller\n function burn(address account, uint256 amount) public {\n _burn(account, amount);\n emit Burning(account, msg.sender, amount);\n }\n\n function setAllowance(address from, address to) public {\n _approve(from, to, type(uint256).max);\n }\n}\n" + }, + "contracts/mock/MockWETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./MockToken.sol\";\n\ncontract MockWETH is MockToken {\n event Deposit(address indexed dst, uint256 wad);\n event Withdrawal(address indexed src, uint256 wad);\n\n receive() external payable {}\n\n /// @notice stablecoin constructor\n /// @param name_ the stablecoin name (example 'agEUR')\n /// @param symbol_ the stablecoin symbol ('agEUR')\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimal_\n ) MockToken(name_, symbol_, decimal_) {}\n\n function deposit() public payable {\n _mint(msg.sender, msg.value);\n emit Deposit(msg.sender, msg.value);\n }\n\n function withdraw(uint256 wad) public {\n _burn(msg.sender, wad);\n (bool sent, ) = msg.sender.call{ value: wad }(\"\");\n require(sent, \"Failed to send Ether\");\n emit Withdrawal(msg.sender, wad);\n }\n}\n" + }, + "contracts/implementations/polygon/AngleRouterPolygon.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterPolygon\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Polygon\ncontract AngleRouterPolygon is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);\n }\n}\n" + }, + "contracts/implementations/optimism/AngleRouterOptimism.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterOptimism\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Optimism\ncontract AngleRouterOptimism is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x4200000000000000000000000000000000000006);\n }\n}\n" + }, + "contracts/implementations/avalanche/AngleRouterAvalanche.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterAvalanche\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Avalanche\ncontract AngleRouterAvalanche is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7);\n }\n}\n" + }, + "contracts/implementations/arbitrum/AngleRouterArbitrum.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterArbitrum\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Arbitrum\ncontract AngleRouterArbitrum is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1);\n }\n}\n" + }, + "contracts/mock/MockBorrowStaker.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ncontract MockBorrowStaker {\n mapping(address => uint256) public counter;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external returns (uint256[] memory) {\n _addr;\n counter[_addr] += 1;\n uint256[] memory returnValue = new uint256[](2);\n returnValue[0] = 1;\n returnValue[1] = 2;\n return returnValue;\n }\n}\n" + }, + "contracts/mock/MockCoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ncontract MockCoreBorrow {\n mapping(address => bool) public governors;\n mapping(address => bool) public guardians;\n\n function isGovernor(address admin) external view returns (bool) {\n return governors[admin];\n }\n\n function isGovernorOrGuardian(address admin) external view returns (bool) {\n return guardians[admin];\n }\n\n function toggleGovernor(address admin) external {\n governors[admin] = !governors[admin];\n }\n\n function toggleGuardian(address admin) external {\n guardians[admin] = !guardians[admin];\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "devdoc", + "userdoc" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/celo/solcInputs/d2039b63af7039fcdbc036f20229f89c.json b/deployments/celo/solcInputs/d2039b63af7039fcdbc036f20229f89c.json new file mode 100644 index 0000000..9ffd022 --- /dev/null +++ b/deployments/celo/solcInputs/d2039b63af7039fcdbc036f20229f89c.json @@ -0,0 +1,94 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n * initialization step. This is essential to configure modules that are added through upgrades and that require\n * initialization.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "@openzeppelin/contracts/interfaces/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(\n uint256 assets,\n address receiver,\n address owner\n ) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(\n uint256 shares,\n address receiver,\n address owner\n ) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 */\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 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/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/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) 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(\n IERC20 token,\n address spender,\n uint256 value\n ) 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 function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\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 if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.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 *\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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, \"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(\n address target,\n bytes memory data,\n uint256 value\n ) 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 require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(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 require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(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 require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason 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 // 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}\n" + }, + "contracts/BaseAngleRouterSidechain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"./interfaces/IAgTokenMultiChain.sol\";\nimport \"./BaseRouter.sol\";\n\n/// @title BaseAngleRouterSidechain\n/// @author Angle Core Team\n/// @notice Extension of the `BaseRouter` contract for sidechains\nabstract contract BaseAngleRouterSidechain is BaseRouter {\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Wrapper built on top of the `_claimRewards` function. It allows to claim rewards for multiple\n /// gauges at once\n /// @param gaugeUser Address for which to fetch the rewards from the gauges\n /// @param liquidityGauges Gauges to claim on\n /// @dev If the caller wants to send the rewards to another account it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function claimRewards(address gaugeUser, address[] calldata liquidityGauges) external {\n _claimRewards(gaugeUser, liquidityGauges);\n }\n\n /// @inheritdoc BaseRouter\n function _chainSpecificAction(ActionType action, bytes calldata data) internal override {\n if (action == ActionType.swapIn) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapIn(canonicalToken, bridgeToken, amount, minAmountOut, to);\n } else if (action == ActionType.swapOut) {\n (address canonicalToken, address bridgeToken, uint256 amount, uint256 minAmountOut, address to) = abi\n .decode(data, (address, address, uint256, uint256, address));\n _swapOut(canonicalToken, bridgeToken, amount, minAmountOut, to);\n }\n }\n\n /// @notice Wraps a bridge token to its corresponding canonical version\n function _swapIn(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapIn(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n\n /// @notice Unwraps a canonical token for one of its bridge version\n function _swapOut(\n address canonicalToken,\n address bridgeToken,\n uint256 amount,\n uint256 minAmountOut,\n address to\n ) internal returns (uint256) {\n amount = IAgTokenMultiChain(canonicalToken).swapOut(bridgeToken, amount, to);\n _slippageCheck(amount, minAmountOut);\n return amount;\n }\n}\n" + }, + "contracts/BaseRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n * █ \n ***** ▓▓▓ \n * ▓▓▓▓▓▓▓ \n * ///. ▓▓▓▓▓▓▓▓▓▓▓▓▓ \n ***** //////// ▓▓▓▓▓▓▓ \n * ///////////// ▓▓▓ \n ▓▓ ////////////////// █ ▓▓ \n ▓▓ ▓▓ /////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ //////////////////////////// ▓▓ ▓▓ \n ▓▓ ▓▓ /////////▓▓▓///////▓▓▓///////// ▓▓ ▓▓ \n ▓▓ ,////////////////////////////////////// ▓▓ ▓▓ \n ▓▓ ////////////////////////////////////////// ▓▓ \n ▓▓ //////////////////////▓▓▓▓///////////////////// \n ,//////////////////////////////////////////////////// \n .////////////////////////////////////////////////////////// \n .//////////////////////////██.,//////////////////////////█ \n .//////////////////////████..,./////////////////////██ \n ...////////////////███████.....,.////////////////███ \n ,.,////////////████████ ........,///////////████ \n .,.,//////█████████ ,.......///////████ \n ,..//████████ ........./████ \n ..,██████ .....,███ \n .██ ,.,█ \n \n \n \n ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ \n ▓▓▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ▓▓▓▓ \n ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓▓▓▓ \n ▓▓▓ ▓▓ ▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ \n*/\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\nimport \"./interfaces/external/uniswap/IUniswapRouter.sol\";\nimport \"./interfaces/external/IWETH9.sol\";\nimport \"./interfaces/ICoreBorrow.sol\";\nimport \"./interfaces/ILiquidityGauge.sol\";\nimport \"./interfaces/ISwapper.sol\";\nimport \"./interfaces/IVaultManager.sol\";\n\n// ============================== STRUCTS AND ENUM =============================\n\n/// @notice Action types\nenum ActionType {\n transfer,\n wrapNative,\n unwrapNative,\n sweep,\n sweepNative,\n uniswapV3,\n oneInch,\n claimRewards,\n gaugeDeposit,\n borrower,\n swapper,\n mint4626,\n deposit4626,\n redeem4626,\n withdraw4626,\n // Deprecated\n prepareRedeemSavingsRate,\n // Deprecated\n claimRedeemSavingsRate,\n swapIn,\n swapOut,\n claimWeeklyInterest,\n withdraw,\n // Deprecated\n mint,\n deposit,\n // Deprecated\n openPerpetual,\n // Deprecated\n addToPerpetual,\n veANGLEDeposit,\n claimRewardsWithPerps\n}\n\n/// @notice Data needed to get permits\nstruct PermitType {\n address token;\n address owner;\n uint256 value;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @notice Data to grant permit to the router for a vault\nstruct PermitVaultManagerType {\n address vaultManager;\n address owner;\n bool approved;\n uint256 deadline;\n uint8 v;\n bytes32 r;\n bytes32 s;\n}\n\n/// @title BaseRouter\n/// @author Angle Core Team\n/// @notice Base contract that Angle router contracts on different chains should override\n/// @dev Router contracts are designed to facilitate the composition of actions on the different modules of the protocol\nabstract contract BaseRouter is Initializable {\n using SafeERC20 for IERC20;\n\n // ================================= REFERENCES ================================\n\n /// @notice Core address handling access control\n ICoreBorrow public core;\n /// @notice Address of the router used for swaps\n IUniswapV3Router public uniswapV3Router;\n /// @notice Address of 1Inch router used for swaps\n address public oneInch;\n\n uint256[47] private __gap;\n\n // ============================== EVENTS / ERRORS ==============================\n\n error IncompatibleLengths();\n error InvalidReturnMessage();\n error NotApprovedOrOwner();\n error NotGovernor();\n error NotGovernorOrGuardian();\n error TooSmallAmountOut();\n error TransferFailed();\n error ZeroAddress();\n\n /// @notice Deploys the router contract on a chain\n function initializeRouter(address _core, address _uniswapRouter, address _oneInch) public initializer {\n if (_core == address(0)) revert ZeroAddress();\n core = ICoreBorrow(_core);\n uniswapV3Router = IUniswapV3Router(_uniswapRouter);\n oneInch = _oneInch;\n }\n\n constructor() initializer {}\n\n // =========================== ROUTER FUNCTIONALITIES ==========================\n\n /// @notice Allows composable calls to different functions within the protocol\n /// @param paramsPermit Array of params `PermitType` used to do a 1 tx to approve the router on each token (can be done once by\n /// setting high approved amounts) which supports the `permit` standard. Users willing to interact with the contract\n /// with tokens that do not support permit should approve the contract for these tokens prior to interacting with it\n /// @param actions List of actions to be performed by the router (in order of execution)\n /// @param data Array of encoded data for each of the actions performed in this mixer. This is where the bytes-encoded parameters\n /// for a given action are stored\n /// @dev With this function, users can specify paths to swap tokens to the desired token of their choice. Yet the protocol\n /// does not verify the payload given and cannot check that the swap performed by users actually gives the desired\n /// out token: in this case funds may be made accessible to anyone on this contract if the concerned users\n /// do not perform a sweep action on these tokens\n function mixer(\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) public payable virtual {\n // If all tokens have already been approved, there's no need for this step\n uint256 permitsLength = paramsPermit.length;\n for (uint256 i; i < permitsLength; ++i) {\n IERC20Permit(paramsPermit[i].token).permit(\n paramsPermit[i].owner,\n address(this),\n paramsPermit[i].value,\n paramsPermit[i].deadline,\n paramsPermit[i].v,\n paramsPermit[i].r,\n paramsPermit[i].s\n );\n }\n // Performing actions one after the others\n uint256 actionsLength = actions.length;\n for (uint256 i; i < actionsLength; ++i) {\n if (actions[i] == ActionType.transfer) {\n (address inToken, address receiver, uint256 amount) = abi.decode(data[i], (address, address, uint256));\n if (amount == type(uint256).max) amount = IERC20(inToken).balanceOf(msg.sender);\n IERC20(inToken).safeTransferFrom(msg.sender, receiver, amount);\n } else if (actions[i] == ActionType.wrapNative) {\n _wrapNative();\n } else if (actions[i] == ActionType.unwrapNative) {\n (uint256 minAmountOut, address to) = abi.decode(data[i], (uint256, address));\n _unwrapNative(minAmountOut, to);\n } else if (actions[i] == ActionType.sweep) {\n (address tokenOut, uint256 minAmountOut, address to) = abi.decode(data[i], (address, uint256, address));\n _sweep(tokenOut, minAmountOut, to);\n } else if (actions[i] == ActionType.sweepNative) {\n uint256 routerBalance = address(this).balance;\n if (routerBalance != 0) _safeTransferNative(msg.sender, routerBalance);\n } else if (actions[i] == ActionType.uniswapV3) {\n (address inToken, uint256 amount, uint256 minAmountOut, bytes memory path) = abi.decode(\n data[i],\n (address, uint256, uint256, bytes)\n );\n _swapOnUniswapV3(IERC20(inToken), amount, minAmountOut, path);\n } else if (actions[i] == ActionType.oneInch) {\n (address inToken, uint256 minAmountOut, bytes memory payload) = abi.decode(\n data[i],\n (address, uint256, bytes)\n );\n _swapOn1Inch(IERC20(inToken), minAmountOut, payload);\n } else if (actions[i] == ActionType.claimRewards) {\n (address user, address[] memory claimLiquidityGauges) = abi.decode(data[i], (address, address[]));\n _claimRewards(user, claimLiquidityGauges);\n } else if (actions[i] == ActionType.gaugeDeposit) {\n (address user, uint256 amount, address gauge, bool shouldClaimRewards) = abi.decode(\n data[i],\n (address, uint256, address, bool)\n );\n _gaugeDeposit(user, amount, ILiquidityGauge(gauge), shouldClaimRewards);\n } else if (actions[i] == ActionType.borrower) {\n (\n address collateral,\n address vaultManager,\n address to,\n address who,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n bytes memory repayData\n ) = abi.decode(data[i], (address, address, address, address, ActionBorrowType[], bytes[], bytes));\n dataBorrow = _parseVaultIDs(actionsBorrow, dataBorrow, vaultManager, collateral);\n _changeAllowance(IERC20(collateral), address(vaultManager), type(uint256).max);\n _angleBorrower(vaultManager, actionsBorrow, dataBorrow, to, who, repayData);\n } else if (actions[i] == ActionType.swapper) {\n (\n ISwapper swapperContract,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory payload\n ) = abi.decode(data[i], (ISwapper, IERC20, IERC20, address, uint256, uint256, bytes));\n _swapper(swapperContract, inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, payload);\n } else if (actions[i] == ActionType.mint4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 shares, address to, uint256 maxAmountIn) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _mint4626(savingsRate, shares, to, maxAmountIn);\n } else if (actions[i] == ActionType.deposit4626) {\n (IERC20 token, IERC4626 savingsRate, uint256 amount, address to, uint256 minSharesOut) = abi.decode(\n data[i],\n (IERC20, IERC4626, uint256, address, uint256)\n );\n _changeAllowance(token, address(savingsRate), type(uint256).max);\n _deposit4626(savingsRate, amount, to, minSharesOut);\n } else if (actions[i] == ActionType.redeem4626) {\n (IERC4626 savingsRate, uint256 shares, address to, uint256 minAmountOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _redeem4626(savingsRate, shares, to, minAmountOut);\n } else if (actions[i] == ActionType.withdraw4626) {\n (IERC4626 savingsRate, uint256 amount, address to, uint256 maxSharesOut) = abi.decode(\n data[i],\n (IERC4626, uint256, address, uint256)\n );\n _withdraw4626(savingsRate, amount, to, maxSharesOut);\n } else {\n _chainSpecificAction(actions[i], data[i]);\n }\n }\n }\n\n /// @notice Wrapper built on top of the base `mixer` function to grant approval to a `VaultManager` contract before performing\n /// actions and then revoking this approval after these actions\n /// @param paramsPermitVaultManager Parameters to sign permit to give allowance to the router for a `VaultManager` contract\n /// @dev In `paramsPermitVaultManager`, the signatures for granting approvals must be given first before the signatures\n /// to revoke approvals\n /// @dev The router contract has been built to be safe to keep approvals as you cannot take an action on a vault you are not\n /// approved for, but people wary about their approvals may want to grant it before immediately revoking it, although this\n /// is just an option\n function mixerVaultManagerPermit(\n PermitVaultManagerType[] memory paramsPermitVaultManager,\n PermitType[] memory paramsPermit,\n ActionType[] calldata actions,\n bytes[] calldata data\n ) external payable virtual {\n uint256 permitVaultManagerLength = paramsPermitVaultManager.length;\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n true,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n } else break;\n }\n mixer(paramsPermit, actions, data);\n // Storing the index at which starting the iteration for revoking approvals in a variable would make the stack\n // too deep\n for (uint256 i; i < permitVaultManagerLength; ++i) {\n if (!paramsPermitVaultManager[i].approved) {\n IVaultManagerFunctions(paramsPermitVaultManager[i].vaultManager).permit(\n paramsPermitVaultManager[i].owner,\n address(this),\n false,\n paramsPermitVaultManager[i].deadline,\n paramsPermitVaultManager[i].v,\n paramsPermitVaultManager[i].r,\n paramsPermitVaultManager[i].s\n );\n }\n }\n }\n\n receive() external payable {}\n\n // ===================== INTERNAL ACTION-RELATED FUNCTIONS =====================\n\n /// @notice Wraps the native token of a chain to its wrapped version\n /// @dev It can be used for ETH to wETH or MATIC to wMATIC\n /// @dev The amount to wrap is to be specified in the `msg.value`\n function _wrapNative() internal virtual returns (uint256) {\n _getNativeWrapper().deposit{ value: msg.value }();\n return msg.value;\n }\n\n /// @notice Unwraps the wrapped version of a token to the native chain token\n /// @dev It can be used for wETH to ETH or wMATIC to MATIC\n function _unwrapNative(uint256 minAmountOut, address to) internal virtual returns (uint256 amount) {\n amount = _getNativeWrapper().balanceOf(address(this));\n _slippageCheck(amount, minAmountOut);\n if (amount != 0) {\n _getNativeWrapper().withdraw(amount);\n _safeTransferNative(to, amount);\n }\n return amount;\n }\n\n /// @notice Internal version of the `claimRewards` function\n /// @dev If the caller wants to send the rewards to another account than `gaugeUser`, it first needs to\n /// call `set_rewards_receiver(otherAccount)` on each `liquidityGauge`\n function _claimRewards(address gaugeUser, address[] memory liquidityGauges) internal virtual {\n uint256 gaugesLength = liquidityGauges.length;\n for (uint256 i; i < gaugesLength; ++i) {\n ILiquidityGauge(liquidityGauges[i]).claim_rewards(gaugeUser);\n }\n }\n\n /// @notice Allows to compose actions on a `VaultManager` (Angle Protocol Borrowing module)\n /// @param vaultManager Address of the vault to perform actions on\n /// @param actionsBorrow Actions type to perform on the vaultManager\n /// @param dataBorrow Data needed for each actions\n /// @param to Address to send the funds to\n /// @param who Swapper address to handle repayments\n /// @param repayData Bytes to use at the discretion of the `msg.sender`\n function _angleBorrower(\n address vaultManager,\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address to,\n address who,\n bytes memory repayData\n ) internal virtual returns (PaymentData memory paymentData) {\n return IVaultManagerFunctions(vaultManager).angle(actionsBorrow, dataBorrow, msg.sender, to, who, repayData);\n }\n\n /// @notice Allows to deposit tokens into a gauge\n /// @param user Address on behalf of which deposits should be made in the gauge\n /// @param amount Amount to stake\n /// @param gauge Liquidity gauge to stake in\n /// @param shouldClaimRewards Whether to claim or not previously accumulated rewards\n /// @dev You should be cautious on who will receive the rewards (if `shouldClaimRewards` is true)\n /// @dev The function will revert if the gauge has not already been approved by the contract\n function _gaugeDeposit(\n address user,\n uint256 amount,\n ILiquidityGauge gauge,\n bool shouldClaimRewards\n ) internal virtual {\n gauge.deposit(amount, user, shouldClaimRewards);\n }\n\n /// @notice Sweeps tokens from the router contract\n /// @param tokenOut Token to sweep\n /// @param minAmountOut Minimum amount of tokens to recover\n /// @param to Address to which tokens should be sent\n function _sweep(address tokenOut, uint256 minAmountOut, address to) internal virtual {\n uint256 balanceToken = IERC20(tokenOut).balanceOf(address(this));\n _slippageCheck(balanceToken, minAmountOut);\n if (balanceToken != 0) {\n IERC20(tokenOut).safeTransfer(to, balanceToken);\n }\n }\n\n /// @notice Uses an external swapper\n /// @param swapper Contracts implementing the logic of the swap\n /// @param inToken Token used to do the swap\n /// @param outToken Token wanted\n /// @param outTokenRecipient Address who should have at the end of the swap at least `outTokenOwed`\n /// @param outTokenOwed Minimal amount for the `outTokenRecipient`\n /// @param inTokenObtained Amount of `inToken` used for the swap\n /// @param data Additional info for the specific swapper\n function _swapper(\n ISwapper swapper,\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) internal {\n swapper.swap(inToken, outToken, outTokenRecipient, outTokenOwed, inTokenObtained, data);\n }\n\n /// @notice Allows to swap between tokens via UniswapV3 (if there is a path)\n /// @param inToken Token used as entrance of the swap\n /// @param amount Amount of in token to swap\n /// @param minAmountOut Minimum amount of outToken accepted for the swap to happen\n /// @param path Bytes representing the path to swap your input token to the accepted collateral\n function _swapOnUniswapV3(\n IERC20 inToken,\n uint256 amount,\n uint256 minAmountOut,\n bytes memory path\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `uniswapV3Router`\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address uniRouter = address(uniswapV3Router);\n _changeAllowance(IERC20(inToken), uniRouter, type(uint256).max);\n amountOut = IUniswapV3Router(uniRouter).exactInput(\n ExactInputParams(path, address(this), block.timestamp, amount, minAmountOut)\n );\n }\n\n /// @notice Swaps an inToken to another token via 1Inch Router\n /// @param payload Bytes needed for 1Inch router to process the swap\n /// @dev The `payload` given is expected to be obtained from 1Inch API\n function _swapOn1Inch(\n IERC20 inToken,\n uint256 minAmountOut,\n bytes memory payload\n ) internal returns (uint256 amountOut) {\n // Approve transfer to the `oneInch` address\n // Since this router is supposed to be a trusted contract, we can leave the allowance to the token\n address oneInchRouter = oneInch;\n _changeAllowance(IERC20(inToken), oneInchRouter, type(uint256).max);\n //solhint-disable-next-line\n (bool success, bytes memory result) = oneInchRouter.call(payload);\n if (!success) _revertBytes(result);\n\n amountOut = abi.decode(result, (uint256));\n _slippageCheck(amountOut, minAmountOut);\n }\n\n /// @notice Mints `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to mint shares from\n /// @param shares Amount of shares to mint from the contract\n /// @param to Address to which shares should be sent\n /// @param maxAmountIn Max amount of assets used to mint\n /// @return amountIn Amount of assets used to mint by `to`\n function _mint4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 maxAmountIn\n ) internal returns (uint256 amountIn) {\n _slippageCheck(maxAmountIn, (amountIn = savingsRate.mint(shares, to)));\n }\n\n /// @notice Deposits `amount` to an ERC4626 contract\n /// @param savingsRate The ERC4626 to deposit assets to\n /// @param amount Amount of assets to deposit\n /// @param to Address to which shares should be sent\n /// @param minSharesOut Minimum amount of shares that `to` should received\n /// @return sharesOut Amount of shares received by `to`\n function _deposit4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(sharesOut = savingsRate.deposit(amount, to), minSharesOut);\n }\n\n /// @notice Withdraws `amount` from an ERC4626 contract\n /// @param savingsRate ERC4626 to withdraw assets from\n /// @param amount Amount of assets to withdraw\n /// @param to Destination of assets\n /// @param maxSharesOut Maximum amount of shares that should be burnt in the operation\n /// @return sharesOut Amount of shares burnt\n function _withdraw4626(\n IERC4626 savingsRate,\n uint256 amount,\n address to,\n uint256 maxSharesOut\n ) internal returns (uint256 sharesOut) {\n _slippageCheck(maxSharesOut, sharesOut = savingsRate.withdraw(amount, to, msg.sender));\n }\n\n /// @notice Redeems `shares` from an ERC4626 contract\n /// @param savingsRate ERC4626 to redeem shares from\n /// @param shares Amount of shares to redeem\n /// @param to Destination of assets\n /// @param minAmountOut Minimum amount of assets that `to` should receive in the redemption process\n /// @return amountOut Amount of assets received by `to`\n function _redeem4626(\n IERC4626 savingsRate,\n uint256 shares,\n address to,\n uint256 minAmountOut\n ) internal returns (uint256 amountOut) {\n _slippageCheck(amountOut = savingsRate.redeem(shares, to, msg.sender), minAmountOut);\n }\n\n /// @notice Allows to perform some specific actions for a chain\n function _chainSpecificAction(ActionType action, bytes calldata data) internal virtual {}\n\n // ======================= VIRTUAL FUNCTIONS TO OVERRIDE =======================\n\n /// @notice Gets the official wrapper of the native token on a chain (like wETH on Ethereum)\n function _getNativeWrapper() internal pure virtual returns (IWETH9);\n\n // ============================ GOVERNANCE FUNCTION ============================\n\n /// @notice Checks whether the `msg.sender` has the governor role or the guardian role\n modifier onlyGovernorOrGuardian() {\n if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();\n _;\n }\n\n /// @notice Sets a new `core` contract\n function setCore(ICoreBorrow _core) external {\n if (!core.isGovernor(msg.sender) || !_core.isGovernor(msg.sender)) revert NotGovernor();\n core = ICoreBorrow(_core);\n }\n\n /// @notice Changes allowances for different tokens\n /// @param tokens Addresses of the tokens to allow\n /// @param spenders Addresses to allow transfer\n /// @param amounts Amounts to allow\n function changeAllowance(\n IERC20[] calldata tokens,\n address[] calldata spenders,\n uint256[] calldata amounts\n ) external onlyGovernorOrGuardian {\n uint256 tokensLength = tokens.length;\n if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();\n for (uint256 i; i < tokensLength; ++i) {\n _changeAllowance(tokens[i], spenders[i], amounts[i]);\n }\n }\n\n /// @notice Sets a new router variable\n function setRouter(address router, uint8 who) external onlyGovernorOrGuardian {\n if (router == address(0)) revert ZeroAddress();\n if (who == 0) uniswapV3Router = IUniswapV3Router(router);\n else oneInch = router;\n }\n\n // ========================= INTERNAL UTILITY FUNCTIONS ========================\n\n /// @notice Changes allowance of this contract for a given token\n /// @param token Address of the token to change allowance\n /// @param spender Address to change the allowance of\n /// @param amount Amount allowed\n function _changeAllowance(IERC20 token, address spender, uint256 amount) internal {\n uint256 currentAllowance = token.allowance(address(this), spender);\n // In case `currentAllowance < type(uint256).max / 2` and we want to increase it:\n // Do nothing (to handle tokens that need reapprovals to 0 and save gas)\n if (currentAllowance < amount && currentAllowance < type(uint256).max / 2) {\n token.safeIncreaseAllowance(spender, amount - currentAllowance);\n } else if (currentAllowance > amount) {\n token.safeDecreaseAllowance(spender, currentAllowance - amount);\n }\n }\n\n /// @notice Transfer amount of the native token to the `to` address\n /// @dev Forked from Solmate: https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol\n function _safeTransferNative(address to, uint256 amount) internal {\n bool success;\n //solhint-disable-next-line\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n if (!success) revert TransferFailed();\n }\n\n /// @notice Parses the actions submitted to the router contract to interact with a `VaultManager` and makes sure that\n /// the calling address is well approved for all the vaults with which it is interacting\n /// @dev If such check was not made, we could end up in a situation where an address has given an approval for all its\n /// vaults to the router contract, and another address takes advantage of this to instruct actions on these other vaults\n /// to the router: it is hence super important for the router to pay attention to the fact that the addresses interacting\n /// with a vault are approved for this vault\n function _parseVaultIDs(\n ActionBorrowType[] memory actionsBorrow,\n bytes[] memory dataBorrow,\n address vaultManager,\n address collateral\n ) internal view returns (bytes[] memory) {\n uint256 actionsBorrowLength = actionsBorrow.length;\n uint256[] memory vaultIDsToCheckOwnershipOf = new uint256[](actionsBorrowLength);\n bool createVaultAction;\n uint256 lastVaultID;\n uint256 vaultIDLength;\n for (uint256 i; i < actionsBorrowLength; ++i) {\n uint256 vaultID;\n // If there is a `createVault` action, the router should not worry about looking at\n // next vaultIDs given equal to 0\n if (actionsBorrow[i] == ActionBorrowType.createVault) {\n createVaultAction = true;\n continue;\n // If the action is a `addCollateral` action, we should check whether a max amount was given to end up adding\n // as collateral the full contract balance\n } else if (actionsBorrow[i] == ActionBorrowType.addCollateral) {\n uint256 amount;\n (vaultID, amount) = abi.decode(dataBorrow[i], (uint256, uint256));\n if (amount == type(uint256).max)\n dataBorrow[i] = abi.encode(vaultID, IERC20(collateral).balanceOf(address(this)));\n continue;\n // There are different ways depending on the action to find the `vaultID` to parse\n } else if (\n actionsBorrow[i] == ActionBorrowType.removeCollateral || actionsBorrow[i] == ActionBorrowType.borrow\n ) {\n (vaultID, ) = abi.decode(dataBorrow[i], (uint256, uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.closeVault) {\n vaultID = abi.decode(dataBorrow[i], (uint256));\n } else if (actionsBorrow[i] == ActionBorrowType.getDebtIn) {\n (vaultID, , , ) = abi.decode(dataBorrow[i], (uint256, address, uint256, uint256));\n } else continue;\n // If we need to add a null `vaultID`, we look at the `vaultIDCount` in the `VaultManager`\n // if there has not been any specific action\n if (vaultID == 0) {\n if (createVaultAction) {\n continue;\n } else {\n // If we haven't stored the last `vaultID`, we need to fetch it\n if (lastVaultID == 0) {\n lastVaultID = IVaultManagerStorage(vaultManager).vaultIDCount();\n }\n vaultID = lastVaultID;\n }\n }\n\n // Check if this `vaultID` has already been verified\n for (uint256 j; j < vaultIDLength; ++j) {\n if (vaultIDsToCheckOwnershipOf[j] == vaultID) {\n // If yes, we continue to the next iteration\n continue;\n }\n }\n // Verify this new `vaultID` and add it to the list\n if (!IVaultManagerFunctions(vaultManager).isApprovedOrOwner(msg.sender, vaultID)) {\n revert NotApprovedOrOwner();\n }\n vaultIDsToCheckOwnershipOf[vaultIDLength] = vaultID;\n vaultIDLength += 1;\n }\n return dataBorrow;\n }\n\n /// @notice Checks whether the amount obtained during a swap is not too small\n function _slippageCheck(uint256 amount, uint256 thresholdAmount) internal pure {\n if (amount < thresholdAmount) revert TooSmallAmountOut();\n }\n\n /// @notice Internal function used for error handling\n function _revertBytes(bytes memory errMsg) internal pure {\n if (errMsg.length != 0) {\n //solhint-disable-next-line\n assembly {\n revert(add(32, errMsg), mload(errMsg))\n }\n }\n revert InvalidReturnMessage();\n }\n}\n" + }, + "contracts/implementations/celo/AngleRouterCelo.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"../../BaseAngleRouterSidechain.sol\";\n\n/// @title AngleRouterCelo\n/// @author Angle Core Team\n/// @notice Router contract built specifially for Angle use cases on Celo\ncontract AngleRouterCelo is BaseAngleRouterSidechain {\n /// @inheritdoc BaseRouter\n /// @dev There is no wCELO contract on CELO\n function _getNativeWrapper() internal pure override returns (IWETH9) {\n return IWETH9(0x0000000000000000000000000000000000000000);\n }\n}\n" + }, + "contracts/interfaces/external/IWETH9.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n /// @notice Deposit ether to get wrapped ether\n function deposit() external payable;\n\n /// @notice Withdraw wrapped ether to get ether\n function withdraw(uint256) external;\n}\n" + }, + "contracts/interfaces/external/uniswap/IUniswapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nstruct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n}\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface IUniswapV3Router {\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\n/// @title Router for price estimation functionality\n/// @notice Functions for getting the price of one token with respect to another using Uniswap V2\n/// @dev This interface is only used for non critical elements of the protocol\ninterface IUniswapV2Router {\n /// @notice Given an input asset amount, returns the maximum output amount of the\n /// other asset (accounting for fees) given reserves.\n /// @param path Addresses of the pools used to get prices\n function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 swapAmount,\n uint256 minExpected,\n address[] calldata path,\n address receiver,\n uint256 swapDeadline\n ) external;\n}\n" + }, + "contracts/interfaces/IAgTokenMultiChain.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title IAgTokenMultiChain\n/// @author Angle Core Team\n/// @notice Interface for the stablecoins `AgToken` contracts in multiple chains\ninterface IAgTokenMultiChain {\n function swapIn(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n\n function swapOut(\n address bridgeToken,\n uint256 amount,\n address to\n ) external returns (uint256);\n}\n" + }, + "contracts/interfaces/ICoreBorrow.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ICoreBorrow\n/// @author Angle Core Team\n/// @notice Interface for the `CoreBorrow` contract\n\ninterface ICoreBorrow {\n /// @notice Checks whether an address is governor of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GOVERNOR_ROLE` or not\n function isGovernor(address admin) external view returns (bool);\n\n /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not\n /// @param admin Address to check\n /// @return Whether the address has the `GUARDIAN_ROLE` or not\n /// @dev Governance should make sure when adding a governor to also give this governor the guardian\n /// role by calling the `addGovernor` function\n function isGovernorOrGuardian(address admin) external view returns (bool);\n}\n" + }, + "contracts/interfaces/ILiquidityGauge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\ninterface ILiquidityGauge {\n // solhint-disable-next-line\n function staking_token() external returns (address stakingToken);\n\n // solhint-disable-next-line\n function deposit_reward_token(address _rewardToken, uint256 _amount) external;\n\n function deposit(\n uint256 _value,\n address _addr,\n // solhint-disable-next-line\n bool _claim_rewards\n ) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr) external;\n\n // solhint-disable-next-line\n function claim_rewards(address _addr, address _receiver) external;\n}\n" + }, + "contracts/interfaces/ISwapper.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\n\n/// @title ISwapper\n/// @author Angle Core Team\n/// @notice Interface for a generic swapper, that supports swaps of higher complexity than aggregators\ninterface ISwapper {\n function swap(\n IERC20 inToken,\n IERC20 outToken,\n address outTokenRecipient,\n uint256 outTokenOwed,\n uint256 inTokenObtained,\n bytes memory data\n ) external;\n}\n" + }, + "contracts/interfaces/ITreasury.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\n/// @title ITreasury\n/// @author Angle Core Team\n/// @notice Interface for the `Treasury` contract\n/// @dev This interface only contains functions of the `Treasury` which are called by other contracts\n/// of this module\ninterface ITreasury {\n /// @notice Checks whether a given address has well been initialized in this contract\n /// as a `VaultManager``\n /// @param _vaultManager Address to check\n /// @return Whether the address has been initialized or not\n function isVaultManager(address _vaultManager) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IVaultManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"./ITreasury.sol\";\n\n// ========================= Key Structs and Enums =============================\n\n/// @notice Data to track during a series of action the amount to give or receive in stablecoins and collateral\n/// to the caller or associated addresses\nstruct PaymentData {\n // Stablecoin amount the contract should give\n uint256 stablecoinAmountToGive;\n // Stablecoin amount owed to the contract\n uint256 stablecoinAmountToReceive;\n // Collateral amount the contract should give\n uint256 collateralAmountToGive;\n // Collateral amount owed to the contract\n uint256 collateralAmountToReceive;\n}\n\n/// @notice Data stored to track someone's loan (or equivalently called position)\nstruct Vault {\n // Amount of collateral deposited in the vault\n uint256 collateralAmount;\n // Normalized value of the debt (that is to say of the stablecoins borrowed)\n uint256 normalizedDebt;\n}\n\n/// @notice Actions possible when composing calls to the different entry functions proposed\nenum ActionBorrowType {\n createVault,\n closeVault,\n addCollateral,\n removeCollateral,\n repayDebt,\n borrow,\n getDebtIn,\n permit\n}\n\n// ========================= Interfaces =============================\n\n/// @title IVaultManagerFunctions\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface only contains functions of the contract which are called by other contracts\n/// of this module (without getters)\ninterface IVaultManagerFunctions {\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Allows composability between calls to the different entry points of this module. Any user calling\n /// this function can perform any of the allowed actions in the order of their choice\n /// @param actions Set of actions to perform\n /// @param datas Data to be decoded for each action: it can include like the `vaultID` or the\n /// @param from Address from which stablecoins will be taken if one action includes burning stablecoins. This address\n /// should either be the `msg.sender` or be approved by the latter\n /// @param to Address to which stablecoins and/or collateral will be sent in case of\n /// @param who Address of the contract to handle in case of repayment of stablecoins from received collateral\n /// @param repayData Data to pass to the repayment contract in case of\n /// @return paymentData Struct containing the final transfers executed\n /// @dev This function is optimized to reduce gas cost due to payment from or to the user and that expensive calls\n /// or computations (like `oracleValue`) are done only once\n function angle(\n ActionBorrowType[] memory actions,\n bytes[] memory datas,\n address from,\n address to,\n address who,\n bytes memory repayData\n ) external payable returns (PaymentData memory paymentData);\n\n /// @notice Checks whether a given address is approved for a vault or owns this vault\n /// @param spender Address for which vault ownership should be checked\n /// @param vaultID ID of the vault to check\n /// @return Whether the `spender` address owns or is approved for `vaultID`\n function isApprovedOrOwner(address spender, uint256 vaultID) external view returns (bool);\n\n /// @notice Allows an address to give or revoke approval for all its vaults to another address\n /// @param owner Address signing the permit and giving (or revoking) its approval for all the controlled vaults\n /// @param spender Address to give approval to\n /// @param approved Whether to give or revoke the approval\n /// @param deadline Deadline parameter for the signature to be valid\n /// @dev The `v`, `r`, and `s` parameters are used as signature data\n function permit(\n address owner,\n address spender,\n bool approved,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n\n/// @title IVaultManagerStorage\n/// @author Angle Core Team\n/// @notice Interface for the `VaultManager` contract\n/// @dev This interface contains getters of the contract's public variables used by other contracts\n/// of this module\ninterface IVaultManagerStorage {\n /// @notice Reference to the `treasury` contract handling this `VaultManager`\n function treasury() external view returns (ITreasury);\n\n /// @notice Reference to the collateral handled by this `VaultManager`\n function collateral() external view returns (IERC20);\n\n /// @notice ID of the last vault created. The `vaultIDCount` variables serves as a counter to generate a unique\n /// `vaultID` for each vault: it is like `tokenID` in basic ERC721 contracts\n function vaultIDCount() external view returns (uint256);\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000000 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates", + "devdoc", + "userdoc" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 3e5a812..07b6fa2 100644 --- a/foundry.toml +++ b/foundry.toml @@ -26,6 +26,6 @@ polygon = "${ETH_NODE_URI_POLYGON}" goerli = "${ETH_NODE_URI_GOERLI}" [etherscan] -mainnet = { key = "$MAINNET_ETHERSCAN_API_KEY}" } +mainnet = { key = "${MAINNET_ETHERSCAN_API_KEY}" } polygon = { key = "${POLYGON_ETHERSCAN_API_KEY}" } goerli = { key = "${GOERLI_ETHERSCAN_API_KEY}" } \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 4a6043f..e4ea823 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -67,8 +67,8 @@ const config: HardhatUserConfig = { forking: { enabled: argv.fork || false, // For mainnet - url: nodeUrl('fork'), - blockNumber: 15975107, + url: nodeUrl('celo'), + blockNumber: 23689026, // For Polygon /* url: nodeUrl('forkpolygon'), @@ -208,6 +208,19 @@ const config: HardhatUserConfig = { }, }, }, + celo: { + live: true, + url: nodeUrl('celo'), + accounts: accounts('celo'), + gas: 'auto', + gasMultiplier: 1.3, + chainId: 42220, + verify: { + etherscan: { + apiKey: etherscanKey('celo'), + }, + }, + }, linea: { live: true, url: nodeUrl('linea'), diff --git a/package.json b/package.json index 03179b3..13f0c2a 100644 --- a/package.json +++ b/package.json @@ -9,15 +9,19 @@ "coverage": "hardhat coverage", "coverage:foundry": "forge coverage --report", "foundry:setup": "curl -L https://foundry.paradigm.xyz | bash && foundryup && git submodule update --init --recursive", - "deploy": "hardhat deploy --network", + "deploy": "hardhat deploy --tags routerSidechain --network", "etherscan": "hardhat etherscan-verify --network", "foundry:test": "forge test -vvvv", "hardhat:compile": "hardhat compile", + "foundry:compile": "forge build", "hardhat:test": "hardhat test", "license": "hardhat prepend-spdx-license", "lint": "yarn lint:sol && yarn lint:js:fix", "lint:js:fix": "eslint --ignore-path .gitignore --fix --max-warnings 30 'test/**/*.{js,ts}' '*.{js,ts}'", "lint:sol": "solhint --fix --max-warnings 20 \"contracts/**/*.sol\"", + "lint:check": "yarn lint:sol:check && yarn lint:js:check", + "lint:js:check": "eslint --ignore-path .gitignore --max-warnings 30 'test/**/*.{js,ts}' '*.{js,ts}'", + "lint:sol:check": "solhint --max-warnings 20 \"**/*.sol\"", "node:fork": "FORK=true hardhat node --tags", "node:instant": "FORK=true hardhat node --tags instant", "prettier": "yarn prettier:js && yarn prettier:sol", @@ -41,7 +45,7 @@ }, "homepage": "https://github.com/AngleProtocol/angle-borrow#readme", "devDependencies": { - "@angleprotocol/sdk": "^3.0.122", + "@angleprotocol/sdk": "1.0.8", "@chainlink/contracts": "0.2.1", "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers", "@nomiclabs/hardhat-etherscan": "3.1.0", @@ -87,7 +91,7 @@ "ganache-cli": "6.12.1", "graphql": "15.5.1", "graphql-request": "3.4.0", - "hardhat": "2.11.1", + "hardhat": "2.19.4", "hardhat-abi-exporter": "2.8.0", "hardhat-contract-sizer": "2.4.0", "hardhat-deploy": "0.11.11", @@ -97,7 +101,7 @@ "mocha": "^9.2.1", "prettier": "2.3.2", "prettier-plugin-solidity": "1.0.0-beta.17", - "solhint": "3.3.6", + "solhint": "3.6.2", "solhint-plugin-prettier": "0.0.5", "solidity-coverage": "^0.8.2", "solidity-docgen": "0.5.13", diff --git a/test/hardhat/router/implementations/arbitrum/AngleRouterArbitrum.test.ts b/scripts/e2e/arbitrum/AngleRouterArbitrum.test.ts similarity index 100% rename from test/hardhat/router/implementations/arbitrum/AngleRouterArbitrum.test.ts rename to scripts/e2e/arbitrum/AngleRouterArbitrum.test.ts diff --git a/test/hardhat/router/implementations/avalanche/AngleRouterAvalanche.test.ts b/scripts/e2e/avalanche/AngleRouterAvalanche.test.ts similarity index 97% rename from test/hardhat/router/implementations/avalanche/AngleRouterAvalanche.test.ts rename to scripts/e2e/avalanche/AngleRouterAvalanche.test.ts index f5f1165..bdfdc8d 100644 --- a/test/hardhat/router/implementations/avalanche/AngleRouterAvalanche.test.ts +++ b/scripts/e2e/avalanche/AngleRouterAvalanche.test.ts @@ -18,10 +18,10 @@ import { MockTokenPermit__factory, MockUniswapV3Router, MockUniswapV3Router__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../utils/helpers'; +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; contract('AngleRouterAvalanche', () => { let deployer: SignerWithAddress; diff --git a/scripts/e2e/base/AngleRouterBase.test.ts b/scripts/e2e/base/AngleRouterBase.test.ts new file mode 100644 index 0000000..62a5b00 --- /dev/null +++ b/scripts/e2e/base/AngleRouterBase.test.ts @@ -0,0 +1,144 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; +import { BigNumber, BytesLike } from 'ethers'; +import { parseEther, parseUnits } from 'ethers/lib/utils'; +import hre, { contract, ethers } from 'hardhat'; + +import { + AngleRouterBase, + AngleRouterBase__factory, + ERC20, + ERC20__factory, + Mock1Inch, + Mock1Inch__factory, + MockAgToken, + MockAgToken__factory, + MockCoreBorrow, + MockCoreBorrow__factory, + MockTokenPermit, + MockTokenPermit__factory, + MockUniswapV3Router, + MockUniswapV3Router__factory, +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; + +contract('AngleRouterBase', () => { + let deployer: SignerWithAddress; + let USDC: MockTokenPermit; + let agEUR: MockAgToken; + let wETH: ERC20; + let core: MockCoreBorrow; + let alice: SignerWithAddress; + let bob: SignerWithAddress; + let uniswap: MockUniswapV3Router; + let oneInch: Mock1Inch; + let router: AngleRouterBase; + let USDCdecimal: BigNumber; + let permits: TypePermit[]; + + before(async () => { + ({ deployer, alice, bob } = await ethers.getNamedSigners()); + USDCdecimal = BigNumber.from('6'); + wETH = (await ethers.getContractAt(ERC20__factory.abi, '0x4200000000000000000000000000000000000006')) as ERC20; + + permits = []; + }); + + beforeEach(async () => { + await hre.network.provider.request({ + method: 'hardhat_reset', + params: [ + { + forking: { + jsonRpcUrl: process.env.ETH_NODE_URI_BASE, + // Changing Base fork block breaks some tests + blockNumber: 13370373, + }, + }, + ], + }); + await hre.network.provider.send('hardhat_setBalance', [alice.address, '0x10000000000000000000000000000']); + // If the forked-network state needs to be reset between each test, run this + router = (await deployUpgradeable(new AngleRouterBase__factory(deployer))) as AngleRouterBase; + USDC = (await new MockTokenPermit__factory(deployer).deploy('USDC', 'USDC', USDCdecimal)) as MockTokenPermit; + agEUR = (await deployUpgradeable(new MockAgToken__factory(deployer))) as MockAgToken; + await agEUR.initialize('agEUR', 'agEUR', ZERO_ADDRESS, ZERO_ADDRESS); + uniswap = (await new MockUniswapV3Router__factory(deployer).deploy( + USDC.address, + agEUR.address, + )) as MockUniswapV3Router; + oneInch = (await new Mock1Inch__factory(deployer).deploy(USDC.address, agEUR.address)) as Mock1Inch; + core = (await new MockCoreBorrow__factory(deployer).deploy()) as MockCoreBorrow; + await core.toggleGovernor(alice.address); + await core.toggleGuardian(alice.address); + await core.toggleGuardian(bob.address); + await router.initializeRouter(core.address, uniswap.address, oneInch.address); + }); + + describe('mixer', () => { + describe('sweepNative', () => { + it('success - amount transferred to the vault', async () => { + await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); + await USDC.connect(alice).approve(router.address, parseUnits('1', USDCdecimal)); + + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, parseUnits('0.3', USDCdecimal)], + ); + const actions = [ActionType.transfer]; + const dataMixer = [transferData]; + + await router.connect(alice).mixer(permits, actions, dataMixer, { value: parseEther('1') }); + + const actions2 = [ActionType.sweepNative]; + const balance = await ethers.provider.getBalance(alice.address); + await router.connect(alice).mixer(permits, actions2, []); + expectApprox((await ethers.provider.getBalance(alice.address)).sub(balance), parseEther('1'), 0.1); + }); + it('success - when there is no ETH balance', async () => { + const actions = [ActionType.sweepNative]; + const balance = await ethers.provider.getBalance(alice.address); + await router.connect(alice).mixer(permits, actions, []); + expectApprox(await ethers.provider.getBalance(alice.address), balance, 0.1); + }); + }); + describe('wrapNative', () => { + it('success - when there is nothing in the action', async () => { + const actions = [ActionType.wrapNative]; + const dataMixer: BytesLike[] = []; + await router.connect(alice).mixer(permits, actions, dataMixer, { value: parseEther('1') }); + expect(await wETH.balanceOf(router.address)).to.be.equal(parseEther('1')); + }); + }); + describe('unwrapNative', () => { + it('success - when there are no wETH', async () => { + const actions = [ActionType.unwrapNative]; + const unwrapData = ethers.utils.defaultAbiCoder.encode(['uint256', 'address'], [0, bob.address]); + await router.connect(alice).mixer(permits, actions, [unwrapData]); + expect(await wETH.balanceOf(router.address)).to.be.equal(parseEther('0')); + expect(await wETH.balanceOf(bob.address)).to.be.equal(parseEther('0')); + }); + it('reverts - because of slippage wETH', async () => { + const actions = [ActionType.unwrapNative]; + const unwrapData = ethers.utils.defaultAbiCoder.encode(['uint256', 'address'], [parseEther('1'), bob.address]); + await expect(router.connect(alice).mixer(permits, actions, [unwrapData])).to.be.revertedWith( + 'TooSmallAmountOut', + ); + }); + it('success - when there are some wETH', async () => { + const actions = [ActionType.wrapNative]; + const dataMixer: BytesLike[] = []; + await router.connect(alice).mixer(permits, actions, dataMixer, { value: parseEther('1') }); + expect(await wETH.balanceOf(router.address)).to.be.equal(parseEther('1')); + const actions2 = [ActionType.unwrapNative]; + const unwrapData = ethers.utils.defaultAbiCoder.encode(['uint256', 'address'], [0, bob.address]); + const balance = await ethers.provider.getBalance(bob.address); + await router.connect(alice).mixer(permits, actions2, [unwrapData]); + expect(await wETH.balanceOf(router.address)).to.be.equal(parseEther('0')); + expect(await wETH.balanceOf(bob.address)).to.be.equal(parseEther('0')); + expect(await ethers.provider.getBalance(bob.address)).to.be.equal(parseEther('1').add(balance)); + }); + }); + }); +}); diff --git a/scripts/e2e/celo/AngleRouterCelo.test.ts b/scripts/e2e/celo/AngleRouterCelo.test.ts new file mode 100644 index 0000000..93d9def --- /dev/null +++ b/scripts/e2e/celo/AngleRouterCelo.test.ts @@ -0,0 +1,116 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; +import { BigNumber, BytesLike } from 'ethers'; +import { parseEther, parseUnits } from 'ethers/lib/utils'; +import hre, { contract, ethers } from 'hardhat'; + +import { + AngleRouterGnosis, + AngleRouterGnosis__factory, + Mock1Inch, + Mock1Inch__factory, + MockAgToken, + MockAgToken__factory, + MockCoreBorrow, + MockCoreBorrow__factory, + MockTokenPermit, + MockTokenPermit__factory, + MockUniswapV3Router, + MockUniswapV3Router__factory, +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; + +contract('AngleRouterCelo', () => { + let deployer: SignerWithAddress; + let USDC: MockTokenPermit; + let agEUR: MockAgToken; + let core: MockCoreBorrow; + let alice: SignerWithAddress; + let bob: SignerWithAddress; + let uniswap: MockUniswapV3Router; + let oneInch: Mock1Inch; + let router: AngleRouterGnosis; + let USDCdecimal: BigNumber; + let permits: TypePermit[]; + + before(async () => { + ({ deployer, alice, bob } = await ethers.getNamedSigners()); + USDCdecimal = BigNumber.from('6'); + permits = []; + }); + + beforeEach(async () => { + await hre.network.provider.request({ + method: 'hardhat_reset', + params: [ + { + forking: { + jsonRpcUrl: process.env.ETH_NODE_URI_CELO, + blockNumber: 23688884, + }, + }, + ], + }); + await hre.network.provider.send('hardhat_setBalance', [alice.address, '0x10000000000000000000000000000']); + // If the forked-network state needs to be reset between each test, run this + router = (await deployUpgradeable(new AngleRouterGnosis__factory(deployer))) as AngleRouterGnosis; + USDC = (await new MockTokenPermit__factory(deployer).deploy('USDC', 'USDC', USDCdecimal)) as MockTokenPermit; + agEUR = (await deployUpgradeable(new MockAgToken__factory(deployer))) as MockAgToken; + await agEUR.initialize('agEUR', 'agEUR', ZERO_ADDRESS, ZERO_ADDRESS); + uniswap = (await new MockUniswapV3Router__factory(deployer).deploy( + USDC.address, + agEUR.address, + )) as MockUniswapV3Router; + oneInch = (await new Mock1Inch__factory(deployer).deploy(USDC.address, agEUR.address)) as Mock1Inch; + core = (await new MockCoreBorrow__factory(deployer).deploy()) as MockCoreBorrow; + await core.toggleGovernor(alice.address); + await core.toggleGuardian(alice.address); + await core.toggleGuardian(bob.address); + await router.initializeRouter(core.address, uniswap.address, oneInch.address); + }); + + describe('mixer', () => { + describe('sweepNative', () => { + it('success - amount transferred to the vault', async () => { + await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); + await USDC.connect(alice).approve(router.address, parseUnits('1', USDCdecimal)); + + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, parseUnits('0.3', USDCdecimal)], + ); + const actions = [ActionType.transfer]; + const dataMixer = [transferData]; + + await router.connect(alice).mixer(permits, actions, dataMixer, { value: parseEther('1') }); + + const actions2 = [ActionType.sweepNative]; + const balance = await ethers.provider.getBalance(alice.address); + await router.connect(alice).mixer(permits, actions2, []); + expectApprox((await ethers.provider.getBalance(alice.address)).sub(balance), parseEther('1'), 0.1); + }); + it('success - when there is no CELO balance', async () => { + const actions = [ActionType.sweepNative]; + const balance = await ethers.provider.getBalance(alice.address); + await router.connect(alice).mixer(permits, actions, []); + expectApprox(await ethers.provider.getBalance(alice.address), balance, 0.1); + }); + }); + describe('wrapNative', () => { + it('reverts - because zero address', async () => { + const actions = [ActionType.wrapNative]; + const dataMixer: BytesLike[] = []; + await expect(router.connect(alice).mixer(permits, actions, dataMixer, { value: parseEther('1') })).to.be + .reverted; + }); + }); + describe('unwrapNative', () => { + it('reverts - because zero address', async () => { + const actions = [ActionType.unwrapNative]; + const unwrapData = ethers.utils.defaultAbiCoder.encode(['uint256', 'address'], [0, bob.address]); + await expect(router.connect(alice).mixer(permits, actions, [unwrapData])).to.be.reverted; + }); + }); + }); +}); diff --git a/test/hardhat/router/implementations/gnosis/AngleRouterGnosis.test.ts b/scripts/e2e/gnosis/AngleRouterGnosis.test.ts similarity index 97% rename from test/hardhat/router/implementations/gnosis/AngleRouterGnosis.test.ts rename to scripts/e2e/gnosis/AngleRouterGnosis.test.ts index e3a6d4d..eac02cd 100644 --- a/test/hardhat/router/implementations/gnosis/AngleRouterGnosis.test.ts +++ b/scripts/e2e/gnosis/AngleRouterGnosis.test.ts @@ -18,10 +18,10 @@ import { MockTokenPermit__factory, MockUniswapV3Router, MockUniswapV3Router__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../utils/helpers'; +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; contract('AngleRouterGnosis', () => { let deployer: SignerWithAddress; diff --git a/scripts/e2e/mainnet/AngleRouterMainnetActions.test.ts b/scripts/e2e/mainnet/AngleRouterMainnetActions.test.ts new file mode 100644 index 0000000..bcc8f5d --- /dev/null +++ b/scripts/e2e/mainnet/AngleRouterMainnetActions.test.ts @@ -0,0 +1,159 @@ +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; +import { parseEther, parseUnits } from 'ethers/lib/utils'; +import { contract, ethers } from 'hardhat'; + +import { + Mock1Inch, + Mock1Inch__factory, + MockAgToken, + MockAgToken__factory, + MockAngleRouterMainnet, + MockAngleRouterMainnet__factory, + MockAngleRouterMainnet2, + MockAngleRouterMainnet2__factory, + MockCoreBorrow, + MockCoreBorrow__factory, + MockFeeDistributor, + MockFeeDistributor__factory, + MockTokenPermit, + MockTokenPermit__factory, + MockUniswapV3Router, + MockUniswapV3Router__factory, + MockVeANGLE, + MockVeANGLE__factory, +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, MAX_UINT256, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; + +contract('AngleRouterMainnet - Actions', () => { + let deployer: SignerWithAddress; + let USDC: MockTokenPermit; + let ANGLE: MockTokenPermit; + let agEUR: MockAgToken; + let veANGLE: MockVeANGLE; + let core: MockCoreBorrow; + let alice: SignerWithAddress; + let bob: SignerWithAddress; + let uniswap: MockUniswapV3Router; + let oneInch: Mock1Inch; + let router: MockAngleRouterMainnet; + let feeDistrib: MockFeeDistributor; + let sanToken: MockTokenPermit; + let permits: TypePermit[]; + + before(async () => { + ({ deployer, alice, bob } = await ethers.getNamedSigners()); + permits = []; + }); + + beforeEach(async () => { + // If the forked-network state needs to be reset between each test, run this + router = (await deployUpgradeable(new MockAngleRouterMainnet__factory(deployer))) as MockAngleRouterMainnet; + USDC = (await new MockTokenPermit__factory(deployer).deploy('USDC', 'USDC', 6)) as MockTokenPermit; + ANGLE = (await new MockTokenPermit__factory(deployer).deploy('ANGLE', 'ANGLE', 18)) as MockTokenPermit; + agEUR = (await deployUpgradeable(new MockAgToken__factory(deployer))) as MockAgToken; + veANGLE = (await new MockVeANGLE__factory(deployer).deploy()) as MockVeANGLE; + veANGLE.setAngle(ANGLE.address); + await agEUR.initialize('agEUR', 'agEUR', ZERO_ADDRESS, ZERO_ADDRESS); + uniswap = (await new MockUniswapV3Router__factory(deployer).deploy( + USDC.address, + agEUR.address, + )) as MockUniswapV3Router; + oneInch = (await new Mock1Inch__factory(deployer).deploy(USDC.address, agEUR.address)) as Mock1Inch; + core = (await new MockCoreBorrow__factory(deployer).deploy()) as MockCoreBorrow; + await core.toggleGovernor(alice.address); + await core.toggleGuardian(alice.address); + await router.setAngleAndVeANGLE(veANGLE.address); + await router.initializeRouter(core.address, uniswap.address, oneInch.address); + sanToken = (await new MockTokenPermit__factory(deployer).deploy('sanUSDC', 'sanUSDC', 6)) as MockTokenPermit; + feeDistrib = (await new MockFeeDistributor__factory(deployer).deploy()) as MockFeeDistributor; + await feeDistrib.setToken(sanToken.address); + }); + describe('getVeANGLE', () => { + it('success - right address', async () => { + const router2 = (await new MockAngleRouterMainnet2__factory(deployer).deploy()) as MockAngleRouterMainnet2; + expect(await router2.getVeANGLE()).to.be.equal('0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5'); + }); + }); + describe('claimWeeklyInterest', () => { + it('success - nothing can be claimed', async () => { + const claimData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'bool'], + [bob.address, feeDistrib.address, false], + ); + const actions = [ActionType.claimWeeklyInterest]; + const dataMixer = [claimData]; + await router.connect(alice).mixer(permits, actions, dataMixer); + expect(await sanToken.balanceOf(bob.address)).to.be.equal(0); + }); + it('success - something can be claimed', async () => { + const claimData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'bool'], + [bob.address, feeDistrib.address, false], + ); + await sanToken.mint(feeDistrib.address, parseEther('1')); + const actions = [ActionType.claimWeeklyInterest]; + const dataMixer = [claimData]; + await router.connect(alice).mixer(permits, actions, dataMixer); + expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseEther('1')); + expect(await sanToken.balanceOf(feeDistrib.address)).to.be.equal(parseEther('0')); + }); + it('reverts - something can be claimed and let in contract but no approval', async () => { + const claimData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'bool'], + [bob.address, feeDistrib.address, true], + ); + await sanToken.mint(feeDistrib.address, parseEther('1')); + const actions = [ActionType.claimWeeklyInterest]; + const dataMixer = [claimData]; + await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.reverted; + }); + it('success - something can be claimed and let in contract and approval', async () => { + const claimData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'bool'], + [bob.address, feeDistrib.address, true], + ); + await sanToken.mint(feeDistrib.address, parseEther('1')); + const actions = [ActionType.claimWeeklyInterest]; + const dataMixer = [claimData]; + await sanToken.connect(bob).approve(router.address, MAX_UINT256); + await router.connect(bob).mixer(permits, actions, dataMixer); + expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseEther('0')); + expect(await sanToken.balanceOf(router.address)).to.be.equal(parseEther('1')); + expect(await sanToken.balanceOf(feeDistrib.address)).to.be.equal(parseEther('0')); + }); + }); + describe('depositOnLocker', () => { + it('success - deposit made', async () => { + await ANGLE.mint(alice.address, parseEther('1')); + await router.connect(alice).changeAllowance([ANGLE.address], [veANGLE.address], [MAX_UINT256]); + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [ANGLE.address, router.address, parseEther('1')], + ); + const depositData = ethers.utils.defaultAbiCoder.encode(['address', 'uint256'], [bob.address, parseEther('1')]); + const actions = [ActionType.transfer, ActionType.veANGLEDeposit]; + const dataMixer = [transferData, depositData]; + await ANGLE.connect(alice).approve(router.address, MAX_UINT256); + await router.connect(alice).mixer(permits, actions, dataMixer); + expect(await ANGLE.balanceOf(veANGLE.address)).to.be.equal(parseEther('1')); + expect(await veANGLE.counter(bob.address)).to.be.equal(parseEther('1')); + }); + }); + describe('unsupported action', () => { + it('success - nothing happens', async () => { + await USDC.mint(alice.address, parseUnits('1', 6)); + await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, parseUnits('0.3', 6)], + ); + const actions = [ActionType.transfer, ActionType.swapIn]; + const dataMixer = [transferData, transferData]; + await router.connect(alice).mixer(permits, actions, dataMixer); + expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.3', 6)); + expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); + }); + }); +}); diff --git a/test/hardhat/router/implementations/mainnet/AngleRouterMainnetWrapping.test.ts b/scripts/e2e/mainnet/AngleRouterMainnetWrapping.test.ts similarity index 95% rename from test/hardhat/router/implementations/mainnet/AngleRouterMainnetWrapping.test.ts rename to scripts/e2e/mainnet/AngleRouterMainnetWrapping.test.ts index 4210f6b..f3fce10 100644 --- a/test/hardhat/router/implementations/mainnet/AngleRouterMainnetWrapping.test.ts +++ b/scripts/e2e/mainnet/AngleRouterMainnetWrapping.test.ts @@ -12,10 +12,10 @@ import { MockCoreBorrow__factory, MockTokenPermit, MockTokenPermit__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, expectApprox } from '../../../utils/helpers'; +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox } from '../../../test/hardhat/utils/helpers'; contract('AngleRouterMainnet - Wrapping logic', () => { let deployer: SignerWithAddress; diff --git a/test/hardhat/router/implementations/optimism/AngleRouterOptimism.test.ts b/scripts/e2e/optimism/AngleRouterOptimism.test.ts similarity index 97% rename from test/hardhat/router/implementations/optimism/AngleRouterOptimism.test.ts rename to scripts/e2e/optimism/AngleRouterOptimism.test.ts index e9eaced..6edf2d6 100644 --- a/test/hardhat/router/implementations/optimism/AngleRouterOptimism.test.ts +++ b/scripts/e2e/optimism/AngleRouterOptimism.test.ts @@ -18,10 +18,10 @@ import { MockTokenPermit__factory, MockUniswapV3Router, MockUniswapV3Router__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../utils/helpers'; +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; contract('AngleRouterOptimism', () => { let deployer: SignerWithAddress; diff --git a/test/hardhat/router/implementations/polygon/AngleRouterPolygon.test.ts b/scripts/e2e/polygon/AngleRouterPolygon.test.ts similarity index 97% rename from test/hardhat/router/implementations/polygon/AngleRouterPolygon.test.ts rename to scripts/e2e/polygon/AngleRouterPolygon.test.ts index 11deec6..2704126 100644 --- a/test/hardhat/router/implementations/polygon/AngleRouterPolygon.test.ts +++ b/scripts/e2e/polygon/AngleRouterPolygon.test.ts @@ -18,10 +18,10 @@ import { MockTokenPermit__factory, MockUniswapV3Router, MockUniswapV3Router__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../utils/helpers'; +} from '../../../typechain'; +import { expect } from '../../../utils/chai-setup'; +import { ActionType, TypePermit } from '../../../utils/helpers'; +import { deployUpgradeable, expectApprox, ZERO_ADDRESS } from '../../../test/hardhat/utils/helpers'; contract('AngleRouterPolygon', () => { let deployer: SignerWithAddress; diff --git a/scripts/mainnet-fork/routerUpgrade.ts b/scripts/mainnet-fork/routerUpgrade.ts index 65e3bd0..eae8dfc 100644 --- a/scripts/mainnet-fork/routerUpgrade.ts +++ b/scripts/mainnet-fork/routerUpgrade.ts @@ -2,9 +2,8 @@ import yargs from 'yargs'; /* simulation script to run on mainnet fork */ import { network, ethers, deployments } from 'hardhat'; // eslint-disable-next-line camelcase -import { AngleRouter, AngleRouter__factory, ProxyAdmin, ProxyAdmin__factory } from '../../typechain'; -import { BigNumber } from 'ethers'; -import { ChainId, CONTRACTS_ADDRESSES } from '@angleprotocol/sdk'; +import { AngleRouterMainnet, AngleRouterMainnet__factory, ProxyAdmin, ProxyAdmin__factory } from '../../typechain'; +import { ChainId, registry } from '@angleprotocol/sdk'; import { expect } from '../../utils/chai-setup'; const argv = yargs.env('').boolean('ci').parseSync(); @@ -13,12 +12,12 @@ async function main() { const { deploy } = deployments; const [deployer] = await ethers.getSigners(); - const collaterals = ['USDC', 'FRAX', 'DAI', 'FEI'] as const; - const chainIdNetwork = ChainId.MAINNET; - const proxyAdminAddress = CONTRACTS_ADDRESSES[chainIdNetwork].ProxyAdmin!; - const governor = CONTRACTS_ADDRESSES[ChainId.MAINNET].GovernanceMultiSig! as string; - const guardian = CONTRACTS_ADDRESSES[ChainId.MAINNET].Guardian! as string; + const proxyAdminAddress = registry(ChainId.MAINNET)?.ProxyAdmin! + const governor = registry(ChainId.MAINNET)?.Governor + const router = registry(ChainId.MAINNET)?.AngleRouterV2! + const core = registry(ChainId.MAINNET)?.CoreBorrow! + await network.provider.request({ method: 'hardhat_impersonateAccount', params: [governor], @@ -26,14 +25,12 @@ async function main() { await network.provider.send('hardhat_setBalance', [governor, '0x10000000000000000000000000000']); const governorSigner = await ethers.provider.getSigner(governor); - const proxyAngleRouterAddress = CONTRACTS_ADDRESSES[chainIdNetwork].AngleRouter!; - - await deploy('AngleRouter_Implementation', { - contract: 'AngleRouter', + await deploy('AngleRouterMainnet_Implementation', { + contract: 'AngleRouterMainnet', from: deployer.address, log: !argv.ci, }); - const AngleRouterImplementation = (await deployments.get('AngleRouter_Implementation')).address; + const AngleRouterImplementation = (await deployments.get('AngleRouterMainnet_Implementation')).address; const contractProxyAdmin = new ethers.Contract( proxyAdminAddress, ProxyAdmin__factory.createInterface(), @@ -41,46 +38,19 @@ async function main() { ) as ProxyAdmin; await ( - await contractProxyAdmin.connect(governorSigner).upgrade(proxyAngleRouterAddress, AngleRouterImplementation) + await contractProxyAdmin.connect(governorSigner).upgrade(router, AngleRouterImplementation) ).wait(); // eslint-disable-next-line camelcase const angleRouter = new ethers.Contract( - proxyAngleRouterAddress, - AngleRouter__factory.createInterface(), + router, + AngleRouterMainnet__factory.createInterface(), governorSigner, - ) as AngleRouter; - - const angleAddress = CONTRACTS_ADDRESSES[chainIdNetwork].ANGLE!; - const veAngleAddress = CONTRACTS_ADDRESSES[chainIdNetwork].veANGLE!; - const WETH9Address = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; - const WSTETHAddress = '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'; - const agEURAddress = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR.AgToken as string; - const stableMasterEURAddress = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR.StableMaster as string; - - const json = await import('../../deploy/networks/mainnet.json'); - - expect(await angleRouter.governor()).to.be.equal(governor); - expect(await angleRouter.guardian()).to.be.equal(guardian); - expect(await angleRouter.ANGLE()).to.be.equal(angleAddress); - expect(await angleRouter.VEANGLE()).to.be.equal(veAngleAddress); - expect(await angleRouter.WETH9()).to.be.equal(WETH9Address); - expect(await angleRouter.WSTETH()).to.be.equal(WSTETHAddress); - expect(await angleRouter.oneInch()).to.be.equal(json.oneInch.Aggregatorv4); - expect(await angleRouter.uniswapV3Router()).to.be.equal(json.Uniswap.RouterV3); + ) as AngleRouterMainnet; - expect(await angleRouter.mapStableMasters(agEURAddress)).to.be.equal(stableMasterEURAddress); - for (const col of collaterals) { - const pair = await angleRouter.mapPoolManagers(stableMasterEURAddress, json[col]); - const poolManager = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.PoolManager as string; - const perpetualManager = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.PerpetualManager as string; - const gauge = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.LiquidityGauge as string; - const sanToken = CONTRACTS_ADDRESSES[chainIdNetwork].agEUR?.collaterals?.[col]?.SanToken as string; - expect(pair[0]).to.be.equal(poolManager); - expect(pair[1]).to.be.equal(perpetualManager); - expect(pair[2]).to.be.equal(sanToken); - expect(pair[3]).to.be.equal(gauge); - } + expect(await angleRouter.core()).to.be.equal(core); + expect(await angleRouter.oneInch()).to.be.equal("0x111111125421cA6dc452d289314280a0f8842A65"); + expect(await angleRouter.uniswapV3Router()).to.be.equal("0xE592427A0AEce92De3Edee1F18E0157C05861564"); console.log('Success'); console.log(''); diff --git a/test/foundry/AngeRouterMainnet.t.sol b/test/foundry/AngeRouterMainnet.t.sol index d5e153d..02ae28a 100644 --- a/test/foundry/AngeRouterMainnet.t.sol +++ b/test/foundry/AngeRouterMainnet.t.sol @@ -61,7 +61,7 @@ contract AngleRouterMainnetTest is BaseTest { address to, uint256 gainOrLoss ) public { - vm.assume(to != address(0) && to != address(router)); + vm.assume(to != address(0) && to != address(router) && to != address(savingsRate)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -101,12 +101,7 @@ contract AngleRouterMainnetTest is BaseTest { assertEq(token.balanceOf(address(to)), 0); } - function testMint4626ForgotFunds( - uint256 initShares, - uint256 shares, - uint256 maxAmount, - uint256 gainOrLoss - ) public { + function testMint4626ForgotFunds(uint256 initShares, uint256 shares, uint256 maxAmount, uint256 gainOrLoss) public { address to = address(router); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -154,7 +149,7 @@ contract AngleRouterMainnetTest is BaseTest { address to, uint256 gainOrLoss ) public { - vm.assume(to != address(0) && to != address(router)); + vm.assume(to != address(0) && to != address(router) && to != address(savingsRate)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -246,7 +241,7 @@ contract AngleRouterMainnetTest is BaseTest { uint256 gainOrLoss, uint256 gainOrLoss2 ) public { - vm.assume(to != address(0) && to != address(router)); + vm.assume(to != address(0) && to != address(router) && to != address(savingsRate)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -401,7 +396,7 @@ contract AngleRouterMainnetTest is BaseTest { uint256 gainOrLoss, uint256 gainOrLoss2 ) public { - vm.assume(to != address(0) && to != address(router)); + vm.assume(to != address(0) && to != address(router) && to != address(savingsRate)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); diff --git a/test/foundry/RouterSidechainSavingsRateActions.t.sol b/test/foundry/RouterSidechainSavingsRateActions.t.sol index 48ee701..b558712 100644 --- a/test/foundry/RouterSidechainSavingsRateActions.t.sol +++ b/test/foundry/RouterSidechainSavingsRateActions.t.sol @@ -67,7 +67,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest { address to, uint256 gainOrLoss ) public { - vm.assume(to != address(0)); + vm.assume(to != address(0) && to != address(savingsRate) && to != address(router)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -119,7 +119,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest { address to, uint256 gainOrLoss ) public { - vm.assume(to != address(0)); + vm.assume(to != address(0) && to != address(savingsRate) && to != address(router)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -170,7 +170,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest { uint256 gainOrLoss, uint256 gainOrLoss2 ) public { - vm.assume(to != address(0)); + vm.assume(to != address(0) && to != address(savingsRate) && to != address(router)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); @@ -248,7 +248,7 @@ contract RouterSidechainSavingsRateActionsTest is BaseTest { uint256 gainOrLoss, uint256 gainOrLoss2 ) public { - vm.assume(to != address(0)); + vm.assume(to != address(0) && to != address(savingsRate) && to != address(router)); uint256 balanceUsers = BASE_TOKENS * 1 ether; deal(address(token), address(_alice), balanceUsers); diff --git a/test/hardhat/router/baseRouter.test.ts b/test/hardhat/router/baseRouter.test.ts index 09001de..b29969b 100644 --- a/test/hardhat/router/baseRouter.test.ts +++ b/test/hardhat/router/baseRouter.test.ts @@ -524,129 +524,6 @@ contract('BaseRouter', () => { }); }); - describe('gaugeDeposit', () => { - it('success - nothing happens when correct gauge', async () => { - const gauge = (await new MockLiquidityGauge__factory(deployer).deploy(USDC.address)) as MockLiquidityGauge; - - const actions = [ActionType.gaugeDeposit]; - const depositData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'address', 'bool'], - [bob.address, 1, gauge.address, true], - ); - const dataMixer = [depositData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - }); - it('reverts - when wrong interface', async () => { - const actions = [ActionType.gaugeDeposit]; - const depositData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'address', 'bool'], - [bob.address, 1, bob.address, true], - ); - const dataMixer = [depositData]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.reverted; - }); - }); - - describe('uniswapV3', () => { - it('reverts - when tokens are not previously sent', async () => { - const swapData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('1', USDCdecimal), 0, '0x'], - ); - const dataMixer = [swapData]; - const actions = [ActionType.uniswapV3]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.reverted; - }); - it('success - swap successfully performed', async () => { - await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); - await USDC.connect(alice).approve(router.address, parseUnits('1', USDCdecimal)); - - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('1', USDCdecimal)], - ); - const swapData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('1', USDCdecimal), 0, '0x'], - ); - const dataMixer = [transferData, swapData]; - const actions = [ActionType.transfer, ActionType.uniswapV3]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(uniswap.address)).to.be.equal(parseUnits('1', USDCdecimal)); - expect(await agEUR.balanceOf(router.address)).to.be.equal(parseEther('1')); - expect(await USDC.allowance(router.address, uniswap.address)).to.be.equal(MAX_UINT256); - }); - it('success - multiple swaps performed', async () => { - await USDC.mint(alice.address, parseUnits('10', USDCdecimal)); - await USDC.connect(alice).approve(router.address, parseUnits('10', USDCdecimal)); - - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('10', USDCdecimal)], - ); - const swapData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('9', USDCdecimal), 0, '0x'], - ); - const swapData2 = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('1', USDCdecimal), 0, '0x'], - ); - const dataMixer = [transferData, swapData, swapData2]; - const actions = [ActionType.transfer, ActionType.uniswapV3, ActionType.uniswapV3]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(uniswap.address)).to.be.equal(parseUnits('10', USDCdecimal)); - expect(await agEUR.balanceOf(router.address)).to.be.equal(parseEther('10')); - expect(await USDC.allowance(router.address, uniswap.address)).to.be.equal(MAX_UINT256); - }); - it('success - swap performed and then swept', async () => { - await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); - await USDC.connect(alice).approve(router.address, parseUnits('1', USDCdecimal)); - - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('1', USDCdecimal)], - ); - const swapData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('1', USDCdecimal), 0, '0x'], - ); - const sweepData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'address'], - [agEUR.address, parseUnits('0', USDCdecimal), bob.address], - ); - const dataMixer = [transferData, swapData, sweepData]; - const actions = [ActionType.transfer, ActionType.uniswapV3, ActionType.sweep]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(uniswap.address)).to.be.equal(parseUnits('1', USDCdecimal)); - expect(await agEUR.balanceOf(bob.address)).to.be.equal(parseEther('1')); - expect(await USDC.allowance(router.address, uniswap.address)).to.be.equal(MAX_UINT256); - }); - it('success - swap performed and then swept with a nice exchange rate', async () => { - await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); - await USDC.connect(alice).approve(router.address, parseUnits('1', USDCdecimal)); - await uniswap.updateExchangeRate(parseEther('0.3')); - - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('1', USDCdecimal)], - ); - const swapData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'uint256', 'bytes'], - [USDC.address, parseUnits('1', USDCdecimal), 0, '0x'], - ); - const sweepData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'address'], - [agEUR.address, parseUnits('0', USDCdecimal), bob.address], - ); - const dataMixer = [transferData, swapData, sweepData]; - const actions = [ActionType.transfer, ActionType.uniswapV3, ActionType.sweep]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(uniswap.address)).to.be.equal(parseUnits('1', USDCdecimal)); - expect(await agEUR.balanceOf(bob.address)).to.be.equal(parseEther('0.3')); - expect(await USDC.allowance(router.address, uniswap.address)).to.be.equal(MAX_UINT256); - }); - }); describe('oneInch', () => { it('success - swap successfully performed', async () => { await USDC.mint(alice.address, parseUnits('1', USDCdecimal)); diff --git a/test/hardhat/router/baseRouter4626.test.ts b/test/hardhat/router/baseRouter4626.test.ts index 917b5fc..98d8646 100644 --- a/test/hardhat/router/baseRouter4626.test.ts +++ b/test/hardhat/router/baseRouter4626.test.ts @@ -14,6 +14,7 @@ import { MockTokenPermit__factory, } from '../../../typechain'; import { expect } from '../../../utils/chai-setup'; +import { inReceipt } from '../../../utils/expectEvent'; import { ActionType, initToken, TypePermit } from '../../../utils/helpers'; import { signPermit } from '../../../utils/sign'; import { deployUpgradeable, MAX_UINT256 } from '../utils/helpers'; @@ -68,6 +69,7 @@ contract('BaseRouter - ERC4626 functionalities', () => { oneInch = (await new Mock1Inch__factory(deployer).deploy(DAI.address, USDC.address)) as Mock1Inch; await router.initializeRouter(alice.address, alice.address, oneInch.address); }); + describe('mixer - mint', () => { it('success - shares minted to the to address - when there are no shares', async () => { const permits: TypePermit[] = [ @@ -539,4 +541,258 @@ contract('BaseRouter - ERC4626 functionalities', () => { expect(await strat2.allowance(alice.address, router.address)).to.be.equal(parseEther('1299')); }); }); + + describe('mixer - deposit with referral', () => { + it('success - shares minted to the to address - when there are no shares', async () => { + const permits: TypePermit[] = [ + await signPermit( + alice, + (await USDC.nonces(alice.address)).toNumber(), + USDC.address, + Number(await (await web3.eth.getBlock('latest')).timestamp) + 1000, + router.address, + UNIT_DAI, + 'USDC', + ), + ]; + + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, UNIT_USDC], + ); + + const mintData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'address', 'uint256', 'address'], + [USDC.address, strat.address, parseUnits('1', 6), bob.address, parseEther('0'), bob.address], + ); + + const actions = [ActionType.transfer, ActionType.deposit4626Referral]; + const dataMixer = [transferData, mintData]; + + const receipt = await (await router.connect(alice).mixer(permits, actions, dataMixer)).wait(); + inReceipt(receipt, 'ReferredDeposit', { + caller: alice.address, + owner: bob.address, + assets: parseUnits('1', 6), + shares: parseEther('1'), + savings: strat.address, + referrer: bob.address, + }); + + expect(await USDC.balanceOf(bob.address)).to.be.equal(0); + expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('999', 6)); + expect(await strat.balanceOf(bob.address)).to.be.equal(parseEther('1')); + expect(await strat.totalSupply()).to.be.equal(parseEther('1')); + expect(await USDC.allowance(router.address, strat.address)).to.be.equal(MAX_UINT256); + }); + it('success - shares minted to the to address - when there are already shares', async () => { + const permits: TypePermit[] = [ + await signPermit( + alice, + (await USDC.nonces(alice.address)).toNumber(), + USDC.address, + Number(await (await web3.eth.getBlock('latest')).timestamp) + 1000, + router.address, + UNIT_DAI, + 'USDC', + ), + ]; + + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, UNIT_USDC], + ); + + const mintData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'address', 'uint256', 'address'], + [USDC.address, strat.address, parseUnits('1', 6), bob.address, parseEther('0'), alice.address], + ); + + const actions = [ActionType.transfer, ActionType.deposit4626Referral]; + const dataMixer = [transferData, mintData]; + + const receipt = await (await router.connect(alice).mixer(permits, actions, dataMixer)).wait(); + + inReceipt(receipt, 'ReferredDeposit', { + caller: alice.address, + owner: bob.address, + assets: parseUnits('1', 6), + shares: parseEther('1'), + savings: strat.address, + referrer: alice.address, + }); + + await USDC.mint(deployer.address, parseUnits('300', 6)); + const transferData2 = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, parseUnits('300', 6)], + ); + const mintData2 = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'address', 'uint256', 'address'], + [USDC.address, strat.address, parseUnits('300', 6), deployer.address, parseEther('100'), USDC.address], + ); + await USDC.connect(deployer).approve(router.address, parseUnits('1000', 6)); + const receipt2 = await ( + await router + .connect(deployer) + .mixer([], [ActionType.transfer, ActionType.deposit4626Referral], [transferData2, mintData2]) + ).wait(); + + inReceipt(receipt2, 'ReferredDeposit', { + caller: deployer.address, + owner: deployer.address, + assets: parseUnits('300', 6), + shares: parseEther('300'), + savings: strat.address, + referrer: USDC.address, + }); + + expect(await USDC.balanceOf(bob.address)).to.be.equal(0); + expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('999', 6)); + expect(await USDC.balanceOf(strat.address)).to.be.equal(parseUnits('301', 6)); + expect(await USDC.balanceOf(deployer.address)).to.be.equal(0); + expect(await strat.balanceOf(bob.address)).to.be.equal(parseEther('1')); + expect(await strat.balanceOf(deployer.address)).to.be.equal(parseEther('300')); + expect(await strat.totalSupply()).to.be.equal(parseEther('301')); + expect(await USDC.allowance(router.address, strat.address)).to.be.equal(MAX_UINT256); + }); + it('reverts - too small amount out', async () => { + const permits: TypePermit[] = [ + await signPermit( + alice, + (await USDC.nonces(alice.address)).toNumber(), + USDC.address, + Number(await (await web3.eth.getBlock('latest')).timestamp) + 1000, + router.address, + UNIT_DAI, + 'USDC', + ), + ]; + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [USDC.address, router.address, UNIT_USDC], + ); + + const mintData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'address', 'uint256', 'address'], + [USDC.address, strat.address, parseUnits('1', 6), bob.address, parseEther('1000'), USDC.address], + ); + + const actions = [ActionType.transfer, ActionType.deposit4626Referral]; + const dataMixer = [transferData, mintData]; + + await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.revertedWith('TooSmallAmountOut'); + }); + it('success - swap and deposit', async () => { + await DAI.mint(alice.address, parseEther('10')); + await DAI.connect(alice).approve(router.address, parseUnits('100', DAIdecimal)); + + const transferData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256'], + [DAI.address, router.address, UNIT_DAI], + ); + const payload1inch = oneInch.interface.encodeFunctionData('swap', [ + ethers.constants.AddressZero, + { + srcToken: DAI.address, + dstToken: USDC.address, + srcReceiver: oneInch.address, + dstReceiver: router.address, + amount: UNIT_DAI, + minReturnAmount: BigNumber.from(0), + flags: BigNumber.from(0), + permit: '0x', + }, + '0x', + ]); + const swapData = ethers.utils.defaultAbiCoder.encode( + ['address', 'uint256', 'bytes'], + [DAI.address, parseEther('0'), payload1inch], + ); + + const mintData = ethers.utils.defaultAbiCoder.encode( + ['address', 'address', 'uint256', 'address', 'uint256', 'address'], + [USDC.address, strat.address, parseUnits('1', 6), bob.address, parseEther('0'), USDC.address], + ); + const dataMixer = [transferData, swapData, mintData]; + const actions = [ActionType.transfer, ActionType.oneInch, ActionType.deposit4626Referral]; + const receipt = await (await router.connect(alice).mixer([], actions, dataMixer)).wait(); + inReceipt(receipt, 'ReferredDeposit', { + caller: alice.address, + owner: bob.address, + assets: parseUnits('1', 6), + shares: parseEther('1'), + savings: strat.address, + referrer: USDC.address, + }); + + expect(await DAI.balanceOf(oneInch.address)).to.be.equal(parseEther('1')); + expect(await USDC.balanceOf(strat.address)).to.be.equal(parseUnits('1', 6)); + + expect(await USDC.balanceOf(bob.address)).to.be.equal(0); + expect(await strat.balanceOf(bob.address)).to.be.equal(parseEther('1')); + expect(await strat.totalSupply()).to.be.equal(parseEther('1')); + expect(await USDC.allowance(router.address, strat.address)).to.be.equal(MAX_UINT256); + }); + }); + describe('deposit4626Referral', () => { + /* + + function deposit4626Referral( + IERC20 token, + IERC4626 savings, + uint256 amount, + address to, + uint256 minSharesOut, + address referrer + ) external { + token.safeTransferFrom(msg.sender, address(this), amount); + _changeAllowance(token, address(savings), type(uint256).max); + _deposit4626Referral(savings, amount, to, minSharesOut, referrer); + } + */ + it('success - deposit successful', async () => { + await USDC.mint(alice.address, parseUnits('1', 6)); + await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); + + await expect( + router + .connect(alice) + .deposit4626Referral( + USDC.address, + strat.address, + parseUnits('1', 6), + bob.address, + parseEther('1.5'), + USDC.address, + ), + ).to.be.revertedWith('TooSmallAmountOut'); + + const receipt = await ( + await router + .connect(alice) + .deposit4626Referral( + USDC.address, + strat.address, + parseUnits('1', 6), + bob.address, + parseEther('0.5'), + USDC.address, + ) + ).wait(); + inReceipt(receipt, 'ReferredDeposit', { + caller: alice.address, + owner: bob.address, + assets: parseUnits('1', 6), + shares: parseEther('1'), + savings: strat.address, + referrer: USDC.address, + }); + expect(await USDC.balanceOf(strat.address)).to.be.equal(parseUnits('1', 6)); + expect(await USDC.balanceOf(bob.address)).to.be.equal(0); + expect(await strat.balanceOf(bob.address)).to.be.equal(parseEther('1')); + expect(await strat.totalSupply()).to.be.equal(parseEther('1')); + expect(await USDC.allowance(router.address, strat.address)).to.be.equal(MAX_UINT256); + }); + }); }); diff --git a/test/hardhat/router/baseRouterVaultManager.test.ts b/test/hardhat/router/baseRouterVaultManager.test.ts index 5d3d4d7..eb44f7f 100644 --- a/test/hardhat/router/baseRouterVaultManager.test.ts +++ b/test/hardhat/router/baseRouterVaultManager.test.ts @@ -8,8 +8,6 @@ import { MockAgToken, MockAgToken__factory, MockTokenPermit, - MockVaultManager, - MockVaultManager__factory, MockVaultManagerPermit, MockVaultManagerPermit__factory, MockVaultManagerPermitCollateral, diff --git a/test/hardhat/router/implementations/mainnet/AngleRouterMainnetActions.test.ts b/test/hardhat/router/implementations/mainnet/AngleRouterMainnetActions.test.ts deleted file mode 100644 index d1920cc..0000000 --- a/test/hardhat/router/implementations/mainnet/AngleRouterMainnetActions.test.ts +++ /dev/null @@ -1,457 +0,0 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { parseEther, parseUnits } from 'ethers/lib/utils'; -import { contract, ethers } from 'hardhat'; - -import { - Mock1Inch, - Mock1Inch__factory, - MockAgToken, - MockAgToken__factory, - MockAngleRouterMainnet, - MockAngleRouterMainnet__factory, - MockAngleRouterMainnet2, - MockAngleRouterMainnet2__factory, - MockCoreBorrow, - MockCoreBorrow__factory, - MockFeeDistributor, - MockFeeDistributor__factory, - MockLiquidityGauge, - MockLiquidityGauge__factory, - MockPerpetualManager, - MockPerpetualManager__factory, - MockStableMaster, - MockStableMaster__factory, - MockTokenPermit, - MockTokenPermit__factory, - MockUniswapV3Router, - MockUniswapV3Router__factory, - MockVeANGLE, - MockVeANGLE__factory, -} from '../../../../../typechain'; -import { expect } from '../../../../../utils/chai-setup'; -import { ActionType, TypePermit } from '../../../../../utils/helpers'; -import { deployUpgradeable, MAX_UINT256, ZERO_ADDRESS } from '../../../utils/helpers'; - -contract('AngleRouterMainnet - Actions', () => { - let deployer: SignerWithAddress; - let USDC: MockTokenPermit; - let ANGLE: MockTokenPermit; - let agEUR: MockAgToken; - let veANGLE: MockVeANGLE; - let core: MockCoreBorrow; - let alice: SignerWithAddress; - let bob: SignerWithAddress; - let uniswap: MockUniswapV3Router; - let oneInch: Mock1Inch; - let router: MockAngleRouterMainnet; - let gauge: MockLiquidityGauge; - let stableMaster: MockStableMaster; - let perpetual: MockPerpetualManager; - let feeDistrib: MockFeeDistributor; - let sanToken: MockTokenPermit; - let permits: TypePermit[]; - - before(async () => { - ({ deployer, alice, bob } = await ethers.getNamedSigners()); - permits = []; - }); - - beforeEach(async () => { - // If the forked-network state needs to be reset between each test, run this - router = (await deployUpgradeable(new MockAngleRouterMainnet__factory(deployer))) as MockAngleRouterMainnet; - USDC = (await new MockTokenPermit__factory(deployer).deploy('USDC', 'USDC', 6)) as MockTokenPermit; - ANGLE = (await new MockTokenPermit__factory(deployer).deploy('ANGLE', 'ANGLE', 18)) as MockTokenPermit; - agEUR = (await deployUpgradeable(new MockAgToken__factory(deployer))) as MockAgToken; - veANGLE = (await new MockVeANGLE__factory(deployer).deploy()) as MockVeANGLE; - veANGLE.setAngle(ANGLE.address); - await agEUR.initialize('agEUR', 'agEUR', ZERO_ADDRESS, ZERO_ADDRESS); - uniswap = (await new MockUniswapV3Router__factory(deployer).deploy( - USDC.address, - agEUR.address, - )) as MockUniswapV3Router; - oneInch = (await new Mock1Inch__factory(deployer).deploy(USDC.address, agEUR.address)) as Mock1Inch; - core = (await new MockCoreBorrow__factory(deployer).deploy()) as MockCoreBorrow; - await core.toggleGovernor(alice.address); - await core.toggleGuardian(alice.address); - await router.setAngleAndVeANGLE(veANGLE.address); - await router.initializeRouter(core.address, uniswap.address, oneInch.address); - sanToken = (await new MockTokenPermit__factory(deployer).deploy('sanUSDC', 'sanUSDC', 6)) as MockTokenPermit; - gauge = (await new MockLiquidityGauge__factory(deployer).deploy(sanToken.address)) as MockLiquidityGauge; - stableMaster = (await new MockStableMaster__factory(deployer).deploy(agEUR.address)) as MockStableMaster; - perpetual = (await new MockPerpetualManager__factory(deployer).deploy()) as MockPerpetualManager; - feeDistrib = (await new MockFeeDistributor__factory(deployer).deploy()) as MockFeeDistributor; - await feeDistrib.setToken(sanToken.address); - }); - describe('getVeANGLE', () => { - it('success - right address', async () => { - const router2 = (await new MockAngleRouterMainnet2__factory(deployer).deploy()) as MockAngleRouterMainnet2; - expect(await router2.getVeANGLE()).to.be.equal('0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5'); - }); - }); - describe('claimRewardsWithPerps', () => { - it('success - when just liquidity gauges', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [], false, [], []], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await gauge.counter(bob.address)).to.be.equal(1); - }); - it('success - when multiple claims', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [], false, [], []], - ); - const actions = [ActionType.claimRewardsWithPerps, ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData, claimData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await gauge.counter(bob.address)).to.be.equal(2); - }); - it('reverts - when incompatible lengths 1/2', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1, 2], true, [ZERO_ADDRESS], [perpetual.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.revertedWith('IncompatibleLengths'); - }); - it('reverts - when incompatible lengths 2/2', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1, 2], true, [ZERO_ADDRESS, ZERO_ADDRESS], [perpetual.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.revertedWith('IncompatibleLengths'); - }); - it('success - when processed perpetual address', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1], true, [ZERO_ADDRESS], [perpetual.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await gauge.counter(bob.address)).to.be.equal(1); - expect(await perpetual.claims(1)).to.be.equal(1); - }); - it('reverts - when not processed and invalid address 1/2', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1], false, [USDC.address], [perpetual.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.revertedWith('ZeroAddress'); - }); - it('reverts - when not processed and invalid address 2/2', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1], false, [agEUR.address], [sanToken.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.revertedWith('ZeroAddress'); - }); - it('success - when not processed address', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address[]', 'uint256[]', 'bool', 'address[]', 'address[]'], - [bob.address, [gauge.address], [1], false, [agEUR.address], [USDC.address]], - ); - const actions = [ActionType.claimRewardsWithPerps]; - const dataMixer = [claimData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await gauge.counter(bob.address)).to.be.equal(1); - expect(await perpetual.claims(1)).to.be.equal(1); - }); - }); - describe('claimWeeklyInterest', () => { - it('success - nothing can be claimed', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'bool'], - [bob.address, feeDistrib.address, false], - ); - const actions = [ActionType.claimWeeklyInterest]; - const dataMixer = [claimData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(0); - }); - it('success - something can be claimed', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'bool'], - [bob.address, feeDistrib.address, false], - ); - await sanToken.mint(feeDistrib.address, parseEther('1')); - const actions = [ActionType.claimWeeklyInterest]; - const dataMixer = [claimData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseEther('1')); - expect(await sanToken.balanceOf(feeDistrib.address)).to.be.equal(parseEther('0')); - }); - it('reverts - something can be claimed and let in contract but no approval', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'bool'], - [bob.address, feeDistrib.address, true], - ); - await sanToken.mint(feeDistrib.address, parseEther('1')); - const actions = [ActionType.claimWeeklyInterest]; - const dataMixer = [claimData]; - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.reverted; - }); - it('success - something can be claimed and let in contract and approval', async () => { - const claimData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'bool'], - [bob.address, feeDistrib.address, true], - ); - await sanToken.mint(feeDistrib.address, parseEther('1')); - const actions = [ActionType.claimWeeklyInterest]; - const dataMixer = [claimData]; - await sanToken.connect(bob).approve(router.address, MAX_UINT256); - await router.connect(bob).mixer(permits, actions, dataMixer); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseEther('0')); - expect(await sanToken.balanceOf(router.address)).to.be.equal(parseEther('1')); - expect(await sanToken.balanceOf(feeDistrib.address)).to.be.equal(parseEther('0')); - }); - }); - describe('depositOnLocker', () => { - it('success - deposit made', async () => { - await ANGLE.mint(alice.address, parseEther('1')); - await router.connect(alice).changeAllowance([ANGLE.address], [veANGLE.address], [MAX_UINT256]); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [ANGLE.address, router.address, parseEther('1')], - ); - const depositData = ethers.utils.defaultAbiCoder.encode(['address', 'uint256'], [bob.address, parseEther('1')]); - const actions = [ActionType.transfer, ActionType.veANGLEDeposit]; - const dataMixer = [transferData, depositData]; - await ANGLE.connect(alice).approve(router.address, MAX_UINT256); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await ANGLE.balanceOf(veANGLE.address)).to.be.equal(parseEther('1')); - expect(await veANGLE.counter(bob.address)).to.be.equal(parseEther('1')); - }); - }); - describe('deposit', () => { - it('success - deposit made when addresses processed', async () => { - await USDC.mint(alice.address, parseUnits('1', 6)); - await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('0.3', 6)], - ); - const mintData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'bool', 'address', 'address', 'address'], - [bob.address, parseUnits('0.3', 6), true, stableMaster.address, ZERO_ADDRESS, alice.address], - ); - const actions = [ActionType.transfer, ActionType.deposit]; - const dataMixer = [transferData, mintData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await USDC.connect(alice).approve(router.address, MAX_UINT256); - await sanToken.mint(stableMaster.address, parseUnits('0.3', 6)); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseUnits('0.3', 6)); - }); - it('success - deposit made when addresses are not processed processed', async () => { - await USDC.mint(alice.address, parseUnits('1', 6)); - await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('0.3', 6)], - ); - const mintData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'bool', 'address', 'address', 'address'], - [bob.address, parseUnits('0.3', 6), false, agEUR.address, USDC.address, ZERO_ADDRESS], - ); - const actions = [ActionType.transfer, ActionType.deposit]; - const dataMixer = [transferData, mintData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await USDC.connect(alice).approve(router.address, MAX_UINT256); - await sanToken.mint(stableMaster.address, parseUnits('0.3', 6)); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseUnits('0.3', 6)); - }); - }); - describe('withdraw', () => { - it('success - withdraw made when addresses processed', async () => { - await router.connect(alice).changeAllowance([sanToken.address], [stableMaster.address], [MAX_UINT256]); - await sanToken.mint(alice.address, parseUnits('1', 6)); - await USDC.mint(stableMaster.address, parseUnits('1', 6)); - await sanToken.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [sanToken.address, router.address, parseUnits('0.3', 6)], - ); - const withdrawData = ethers.utils.defaultAbiCoder.encode( - ['uint256', 'bool', 'address', 'address', 'address'], - [parseUnits('0.3', 6), true, stableMaster.address, alice.address, ZERO_ADDRESS], - ); - const actions = [ActionType.transfer, ActionType.withdraw]; - const dataMixer = [transferData, withdrawData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await sanToken.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.3', 6)); - }); - it('success - withdraw made when addresses processed and leftover', async () => { - await router.connect(alice).changeAllowance([sanToken.address], [stableMaster.address], [MAX_UINT256]); - await sanToken.mint(alice.address, parseUnits('1', 6)); - await USDC.mint(stableMaster.address, parseUnits('1', 6)); - await sanToken.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [sanToken.address, router.address, parseUnits('0.3', 6)], - ); - const withdrawData = ethers.utils.defaultAbiCoder.encode( - ['uint256', 'bool', 'address', 'address', 'address'], - [parseUnits('0.2', 6), true, stableMaster.address, alice.address, ZERO_ADDRESS], - ); - const actions = [ActionType.transfer, ActionType.withdraw]; - const dataMixer = [transferData, withdrawData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.8', 6)); - expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.2', 6)); - expect(await sanToken.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.2', 6)); - expect(await sanToken.balanceOf(router.address)).to.be.equal(parseUnits('0.1', 6)); - }); - it('reverts - withdraw made when addresses processed and no leftover because max uint but no sanToken address', async () => { - await router.connect(alice).changeAllowance([sanToken.address], [stableMaster.address], [MAX_UINT256]); - await sanToken.mint(alice.address, parseUnits('1', 6)); - await USDC.mint(stableMaster.address, parseUnits('1', 6)); - await sanToken.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [sanToken.address, router.address, parseUnits('0.3', 6)], - ); - const withdrawData = ethers.utils.defaultAbiCoder.encode( - ['uint256', 'bool', 'address', 'address', 'address'], - [MAX_UINT256, true, stableMaster.address, alice.address, ZERO_ADDRESS], - ); - const actions = [ActionType.transfer, ActionType.withdraw]; - const dataMixer = [transferData, withdrawData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await expect(router.connect(alice).mixer(permits, actions, dataMixer)).to.be.reverted; - }); - it('success - withdraw made when addresses not processed 1/2', async () => { - await router.connect(alice).changeAllowance([sanToken.address], [stableMaster.address], [MAX_UINT256]); - await sanToken.mint(alice.address, parseUnits('1', 6)); - await USDC.mint(stableMaster.address, parseUnits('1', 6)); - await sanToken.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [sanToken.address, router.address, parseUnits('0.3', 6)], - ); - const withdrawData = ethers.utils.defaultAbiCoder.encode( - ['uint256', 'bool', 'address', 'address', 'address'], - [MAX_UINT256, false, agEUR.address, USDC.address, sanToken.address], - ); - const actions = [ActionType.transfer, ActionType.withdraw]; - const dataMixer = [transferData, withdrawData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await sanToken.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.3', 6)); - }); - it('success - withdraw made when addresses not processed 2/2', async () => { - await router.connect(alice).changeAllowance([sanToken.address], [stableMaster.address], [MAX_UINT256]); - await sanToken.mint(alice.address, parseUnits('1', 6)); - await USDC.mint(stableMaster.address, parseUnits('1', 6)); - await sanToken.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [sanToken.address, router.address, parseUnits('0.3', 6)], - ); - const withdrawData = ethers.utils.defaultAbiCoder.encode( - ['uint256', 'bool', 'address', 'address', 'address'], - [parseUnits('0.2', 6), false, agEUR.address, USDC.address, sanToken.address], - ); - const actions = [ActionType.transfer, ActionType.withdraw]; - const dataMixer = [transferData, withdrawData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.8', 6)); - expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.2', 6)); - expect(await sanToken.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.2', 6)); - expect(await sanToken.balanceOf(router.address)).to.be.equal(parseUnits('0.1', 6)); - }); - }); - describe('unsupported action', () => { - it('success - nothing happens', async () => { - await USDC.mint(alice.address, parseUnits('1', 6)); - await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('0.3', 6)], - ); - const actions = [ActionType.transfer, ActionType.swapIn]; - const dataMixer = [transferData, transferData]; - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(router.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - }); - }); - describe('Composed actions', () => { - describe('deposit & stake', () => { - it('success - flow works correctly', async () => { - await USDC.mint(alice.address, parseUnits('1', 6)); - await USDC.connect(alice).approve(router.address, parseUnits('1', 6)); - const transferData = ethers.utils.defaultAbiCoder.encode( - ['address', 'address', 'uint256'], - [USDC.address, router.address, parseUnits('0.3', 6)], - ); - const mintData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'bool', 'address', 'address', 'address'], - [router.address, parseUnits('0.3', 6), true, stableMaster.address, ZERO_ADDRESS, alice.address], - ); - const gaugeData = ethers.utils.defaultAbiCoder.encode( - ['address', 'uint256', 'address', 'bool'], - [bob.address, parseUnits('0.3', 6), gauge.address, false], - ); - const actions = [ActionType.transfer, ActionType.deposit, ActionType.gaugeDeposit]; - const dataMixer = [transferData, mintData, gaugeData]; - await router.connect(alice).addStableMaster(agEUR.address, stableMaster.address); - await stableMaster.addCollateral(alice.address, USDC.address, sanToken.address, perpetual.address); - await router.connect(alice).addPairs([agEUR.address], [alice.address], [gauge.address], [false]); - await USDC.connect(alice).approve(router.address, MAX_UINT256); - await sanToken.mint(stableMaster.address, parseUnits('0.3', 6)); - await router.connect(alice).mixer(permits, actions, dataMixer); - expect(await USDC.balanceOf(stableMaster.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await USDC.balanceOf(alice.address)).to.be.equal(parseUnits('0.7', 6)); - expect(await sanToken.balanceOf(bob.address)).to.be.equal(parseUnits('0', 6)); - expect(await sanToken.balanceOf(router.address)).to.be.equal(parseUnits('0.3', 6)); - expect(await gauge.counter2(bob.address)).to.be.equal(1); - }); - }); - }); -}); diff --git a/utils/helpers.ts b/utils/helpers.ts index decce9e..5e2f73b 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -97,4 +97,5 @@ export enum ActionType { addToPerpetual, veANGLEDeposit, claimRewardsWithPerps, + deposit4626Referral } diff --git a/yarn.lock b/yarn.lock index 418b815..6605ea8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,12 @@ # yarn lockfile v1 -"@angleprotocol/sdk@^3.0.122": - version "3.0.122" - resolved "https://registry.yarnpkg.com/@angleprotocol/sdk/-/sdk-3.0.122.tgz#4a9a4ab0305e900728893d02454c8972ad6428c5" - integrity sha512-pDrj+Oqj1TTJJfcmm/7Csr21cT3o0oktYU7Y/IY/kLB7K3ht1fDOWl5sGT8VXiyE+serW/ZUlCyX7njDpeqWYQ== +"@angleprotocol/sdk@1.0.8": + version "1.0.8" + resolved "https://npm.pkg.github.com/download/@angleprotocol/sdk/1.0.8/d94207a89943a2553c5d5974b2c29dcaf8bf1d75#d94207a89943a2553c5d5974b2c29dcaf8bf1d75" + integrity sha512-6mYynQ5GXI+eTzTWD75rczYD0Y0NICrJRyKlqnNZ2BOPoWLuyGOVuGOzoBNPghxl0DgW5ZNMjl3WXpmlOtpAAg== dependencies: + "@apollo/client" "^3.7.17" "@typechain/ethers-v5" "^10.0.0" "@types/lodash" "^4.14.180" ethers "^5.6.4" @@ -17,7 +18,25 @@ lodash "^4.17.21" merkletreejs "^0.3.10" tiny-invariant "^1.1.0" - typechain "^8.0.0" + typechain "^8.3.2" + +"@apollo/client@^3.7.17": + version "3.8.10" + resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.8.10.tgz#db6ee4378212d93c1f22b90a2aa474f6e9664b68" + integrity sha512-p/22RZ8ehHyvySnC20EHPPe0gdu8Xp6ZCiXOfdEe1ZORw5cUteD/TLc66tfKv8qu8NLIfbiWoa+6s70XnKvxqg== + dependencies: + "@graphql-typed-document-node/core" "^3.1.1" + "@wry/equality" "^0.5.6" + "@wry/trie" "^0.5.0" + graphql-tag "^2.12.6" + hoist-non-react-statics "^3.3.2" + optimism "^0.18.0" + prop-types "^15.7.2" + response-iterator "^0.2.6" + symbol-observable "^4.0.0" + ts-invariant "^0.10.3" + tslib "^2.3.0" + zen-observable-ts "^1.2.5" "@babel/code-frame@7.12.11": version "7.12.11" @@ -64,6 +83,42 @@ resolved "https://registry.yarnpkg.com/@chainlink/contracts/-/contracts-0.2.1.tgz#0815901baa4634b7b41b4e747f3425e2c968fb85" integrity sha512-mAQgPQKiqW3tLMlp31NgcnXpwG3lttgKU0izAqKiirJ9LH7rQ+O0oHIVR5Qp2yuqgmfbLsgfdLo4GcVC8IFz3Q== +"@chainsafe/as-sha256@^0.3.1": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz#3639df0e1435cab03f4d9870cc3ac079e57a6fc9" + integrity sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg== + +"@chainsafe/persistent-merkle-tree@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.4.2.tgz#4c9ee80cc57cd3be7208d98c40014ad38f36f7ff" + integrity sha512-lLO3ihKPngXLTus/L7WHKaw9PnNJWizlOF1H9NNzHP6Xvh82vzg9F2bzkXhYIFshMZ2gTCEz8tq6STe7r5NDfQ== + dependencies: + "@chainsafe/as-sha256" "^0.3.1" + +"@chainsafe/persistent-merkle-tree@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.5.0.tgz#2b4a62c9489a5739dedd197250d8d2f5427e9f63" + integrity sha512-l0V1b5clxA3iwQLXP40zYjyZYospQLZXzBVIhhr9kDg/1qHZfzzHw0jj4VPBijfYCArZDlPkRi1wZaV2POKeuw== + dependencies: + "@chainsafe/as-sha256" "^0.3.1" + +"@chainsafe/ssz@^0.10.0": + version "0.10.2" + resolved "https://registry.yarnpkg.com/@chainsafe/ssz/-/ssz-0.10.2.tgz#c782929e1bb25fec66ba72e75934b31fd087579e" + 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.2": + version "0.9.4" + resolved "https://registry.yarnpkg.com/@chainsafe/ssz/-/ssz-0.9.4.tgz#696a8db46d6975b600f8309ad3a12f7c0e310497" + integrity sha512-77Qtg2N1ayqs4Bg/wvnWfg5Bta7iy7IRh8XqXh7oNMeP2HBbBwx8m6yTpA8p0EHItWPEBkgZd5S5/LSlp3GXuQ== + dependencies: + "@chainsafe/as-sha256" "^0.3.1" + "@chainsafe/persistent-merkle-tree" "^0.4.2" + case "^1.6.3" + "@colors/colors@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" @@ -576,6 +631,13 @@ dependencies: "@ethersproject/logger" "^5.7.0" +"@ethersproject/networks@5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.7.1.tgz#118e1a981d757d45ccea6bb58d9fd3d9db14ead6" + integrity sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ== + dependencies: + "@ethersproject/logger" "^5.7.0" + "@ethersproject/pbkdf2@5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.5.0.tgz#e25032cdf02f31505d47afbf9c3e000d95c4a050" @@ -657,6 +719,32 @@ bech32 "1.1.4" ws "7.4.6" +"@ethersproject/providers@5.7.2", "@ethersproject/providers@^5.7.1", "@ethersproject/providers@^5.7.2": + version "5.7.2" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" + 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.0" + "@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.0" + bech32 "1.1.4" + ws "7.4.6" + "@ethersproject/random@5.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.5.0.tgz#305ed9e033ca537735365ac12eed88580b0f81f9" @@ -885,6 +973,17 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@ethersproject/web@5.7.1": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.7.1.tgz#de1f285b373149bee5928f4eb7bcb87ee5fbb4ae" + 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.5.0": version "5.5.0" resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.5.0.tgz#aac74963aa43e643638e5172353d931b347d584f" @@ -907,6 +1006,11 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@fastify/busboy@^2.0.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.0.tgz#0709e9f4cb252351c609c6e6d8d6779a8d25edff" + integrity sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA== + "@fvictorio/tabtab@^0.0.3": version "0.0.3" resolved "https://registry.yarnpkg.com/@fvictorio/tabtab/-/tabtab-0.0.3.tgz#1b97981424386490fa2a5818706d2afd1f6e4659" @@ -918,6 +1022,11 @@ mkdirp "^1.0.3" untildify "^4.0.0" +"@graphql-typed-document-node/core@^3.1.1": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" + integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== + "@humanwhocodes/config-array@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" @@ -1031,29 +1140,31 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@nomicfoundation/ethereumjs-block@^4.0.0", "@nomicfoundation/ethereumjs-block@^4.0.0-rc.3": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-4.0.0.tgz#fdd5c045e7baa5169abeed0e1202bf94e4481c49" - integrity sha512-bk8uP8VuexLgyIZAHExH1QEovqx0Lzhc9Ntm63nCRKLHXIZkobaFaeCVwTESV7YkPKUk7NiK11s8ryed4CS9yA== - dependencies: - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-trie" "^5.0.0" - "@nomicfoundation/ethereumjs-tx" "^4.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" +"@nomicfoundation/ethereumjs-block@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-5.0.2.tgz#13a7968f5964f1697da941281b7f7943b0465d04" + integrity sha512-hSe6CuHI4SsSiWWjHDIzWhSiAVpzMUcDRpWYzN0T9l8/Rz7xNn3elwVOJ/tAyS0LqL6vitUD78Uk7lQDXZun7Q== + 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.1" -"@nomicfoundation/ethereumjs-blockchain@^6.0.0", "@nomicfoundation/ethereumjs-blockchain@^6.0.0-rc.3": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-6.0.0.tgz#1a8c243a46d4d3691631f139bfb3a4a157187b0c" - integrity sha512-pLFEoea6MWd81QQYSReLlLfH7N9v7lH66JC/NMPN848ySPPQA5renWnE7wPByfQFzNrPBuDDRFFULMDmj1C0xw== - dependencies: - "@nomicfoundation/ethereumjs-block" "^4.0.0" - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-ethash" "^2.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-trie" "^5.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" +"@nomicfoundation/ethereumjs-blockchain@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-7.0.2.tgz#45323b673b3d2fab6b5008535340d1b8fea7d446" + integrity sha512-8UUsSXJs+MFfIIAKdh3cG16iNmWzWC/91P40sazNvrqhhdR/RtGDlFk2iFTGbBAZPs2+klZVzhRX8m2wvuvz3w== + 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.3" debug "^4.3.3" ethereum-cryptography "0.1.3" @@ -1061,173 +1172,173 @@ lru-cache "^5.1.1" memory-level "^1.0.0" -"@nomicfoundation/ethereumjs-common@^3.0.0", "@nomicfoundation/ethereumjs-common@^3.0.0-rc.3": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-3.0.0.tgz#f6bcc7753994555e49ab3aa517fc8bcf89c280b9" - integrity sha512-WS7qSshQfxoZOpHG/XqlHEGRG1zmyjYrvmATvc4c62+gZXgre1ymYP8ZNgx/3FyZY0TWe9OjFlKOfLqmgOeYwA== +"@nomicfoundation/ethereumjs-common@4.0.2": + version "4.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-4.0.2.tgz#a15d1651ca36757588fdaf2a7d381a150662a3c3" + integrity sha512-I2WGP3HMGsOoycSdOTSqIaES0ughQTueOsddJ36aYVpI3SN8YSusgRFLwzDJwRFVIYDKx/iJz0sQ5kBHVgdDwg== dependencies: - "@nomicfoundation/ethereumjs-util" "^8.0.0" + "@nomicfoundation/ethereumjs-util" "9.0.2" crc-32 "^1.2.0" -"@nomicfoundation/ethereumjs-ethash@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-2.0.0.tgz#11539c32fe0990e1122ff987d1b84cfa34774e81" - integrity sha512-WpDvnRncfDUuXdsAXlI4lXbqUDOA+adYRQaEezIkxqDkc+LDyYDbd/xairmY98GnQzo1zIqsIL6GB5MoMSJDew== +"@nomicfoundation/ethereumjs-ethash@3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-3.0.2.tgz#da77147f806401ee996bfddfa6487500118addca" + integrity sha512-8PfoOQCcIcO9Pylq0Buijuq/O73tmMVURK0OqdjhwqcGHYC2PwhbajDh7GZ55ekB0Px197ajK3PQhpKoiI/UPg== dependencies: - "@nomicfoundation/ethereumjs-block" "^4.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" + "@nomicfoundation/ethereumjs-block" "5.0.2" + "@nomicfoundation/ethereumjs-rlp" "5.0.2" + "@nomicfoundation/ethereumjs-util" "9.0.2" abstract-level "^1.0.3" bigint-crypto-utils "^3.0.23" ethereum-cryptography "0.1.3" -"@nomicfoundation/ethereumjs-evm@^1.0.0", "@nomicfoundation/ethereumjs-evm@^1.0.0-rc.3": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-1.0.0.tgz#99cd173c03b59107c156a69c5e215409098a370b" - integrity sha512-hVS6qRo3V1PLKCO210UfcEQHvlG7GqR8iFzp0yyjTg2TmJQizcChKgWo8KFsdMw6AyoLgLhHGHw4HdlP8a4i+Q== +"@nomicfoundation/ethereumjs-evm@2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-2.0.2.tgz#4c2f4b84c056047102a4fa41c127454e3f0cfcf6" + integrity sha512-rBLcUaUfANJxyOx9HIdMX6uXGin6lANCulIm/pjMgRqfiCRMZie3WKYxTSd8ZE/d+qT+zTedBF4+VHTdTSePmQ== dependencies: - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" - "@types/async-eventemitter" "^0.2.1" - async-eventemitter "^0.2.4" + "@ethersproject/providers" "^5.7.1" + "@nomicfoundation/ethereumjs-common" "4.0.2" + "@nomicfoundation/ethereumjs-tx" "5.0.2" + "@nomicfoundation/ethereumjs-util" "9.0.2" debug "^4.3.3" ethereum-cryptography "0.1.3" mcl-wasm "^0.7.1" rustbn.js "~0.2.0" -"@nomicfoundation/ethereumjs-rlp@^4.0.0", "@nomicfoundation/ethereumjs-rlp@^4.0.0-beta.2", "@nomicfoundation/ethereumjs-rlp@^4.0.0-rc.3": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-4.0.0.tgz#d9a9c5f0f10310c8849b6525101de455a53e771d" - integrity sha512-GaSOGk5QbUk4eBP5qFbpXoZoZUj/NrW7MRa0tKY4Ew4c2HAS0GXArEMAamtFrkazp0BO4K5p2ZCG3b2FmbShmw== +"@nomicfoundation/ethereumjs-rlp@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-5.0.2.tgz#4fee8dc58a53ac6ae87fb1fca7c15dc06c6b5dea" + integrity sha512-QwmemBc+MMsHJ1P1QvPl8R8p2aPvvVcKBbvHnQOKBpBztEo0omN0eaob6FeZS/e3y9NSe+mfu3nNFBHszqkjTA== -"@nomicfoundation/ethereumjs-statemanager@^1.0.0", "@nomicfoundation/ethereumjs-statemanager@^1.0.0-rc.3": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-1.0.0.tgz#14a9d4e1c828230368f7ab520c144c34d8721e4b" - integrity sha512-jCtqFjcd2QejtuAMjQzbil/4NHf5aAWxUc+CvS0JclQpl+7M0bxMofR2AJdtz+P3u0ke2euhYREDiE7iSO31vQ== +"@nomicfoundation/ethereumjs-statemanager@2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-2.0.2.tgz#3ba4253b29b1211cafe4f9265fee5a0d780976e0" + integrity sha512-dlKy5dIXLuDubx8Z74sipciZnJTRSV/uHG48RSijhgm1V7eXYFC567xgKtsKiVZB1ViTP9iFL4B6Je0xD6X2OA== dependencies: - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-trie" "^5.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" + "@nomicfoundation/ethereumjs-common" "4.0.2" + "@nomicfoundation/ethereumjs-rlp" "5.0.2" debug "^4.3.3" ethereum-cryptography "0.1.3" - functional-red-black-tree "^1.0.1" + ethers "^5.7.1" + js-sdsl "^4.1.4" -"@nomicfoundation/ethereumjs-trie@^5.0.0", "@nomicfoundation/ethereumjs-trie@^5.0.0-rc.3": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-5.0.0.tgz#dcfbe3be53a94bc061c9767a396c16702bc2f5b7" - integrity sha512-LIj5XdE+s+t6WSuq/ttegJzZ1vliwg6wlb+Y9f4RlBpuK35B9K02bO7xU+E6Rgg9RGptkWd6TVLdedTI4eNc2A== +"@nomicfoundation/ethereumjs-trie@6.0.2": + version "6.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-6.0.2.tgz#9a6dbd28482dca1bc162d12b3733acab8cd12835" + integrity sha512-yw8vg9hBeLYk4YNg5MrSJ5H55TLOv2FSWUTROtDtTMMmDGROsAu+0tBjiNGTnKRi400M6cEzoFfa89Fc5k8NTQ== dependencies: - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" + "@nomicfoundation/ethereumjs-rlp" "5.0.2" + "@nomicfoundation/ethereumjs-util" "9.0.2" + "@types/readable-stream" "^2.3.13" ethereum-cryptography "0.1.3" readable-stream "^3.6.0" -"@nomicfoundation/ethereumjs-tx@^4.0.0", "@nomicfoundation/ethereumjs-tx@^4.0.0-rc.3": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-4.0.0.tgz#59dc7452b0862b30342966f7052ab9a1f7802f52" - integrity sha512-Gg3Lir2lNUck43Kp/3x6TfBNwcWC9Z1wYue9Nz3v4xjdcv6oDW9QSMJxqsKw9QEGoBBZ+gqwpW7+F05/rs/g1w== - dependencies: - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" +"@nomicfoundation/ethereumjs-tx@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-5.0.2.tgz#117813b69c0fdc14dd0446698a64be6df71d7e56" + integrity sha512-T+l4/MmTp7VhJeNloMkM+lPU3YMUaXdcXgTGCf8+ZFvV9NYZTRLFekRwlG6/JMmVfIfbrW+dRRJ9A6H5Q/Z64g== + dependencies: + "@chainsafe/ssz" "^0.9.2" + "@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" -"@nomicfoundation/ethereumjs-util@^8.0.0", "@nomicfoundation/ethereumjs-util@^8.0.0-rc.3": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-8.0.0.tgz#deb2b15d2c308a731e82977aefc4e61ca0ece6c5" - integrity sha512-2emi0NJ/HmTG+CGY58fa+DQuAoroFeSH9gKu9O6JnwTtlzJtgfTixuoOqLEgyyzZVvwfIpRueuePb8TonL1y+A== +"@nomicfoundation/ethereumjs-util@9.0.2": + version "9.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-9.0.2.tgz#16bdc1bb36f333b8a3559bbb4b17dac805ce904d" + integrity sha512-4Wu9D3LykbSBWZo8nJCnzVIYGvGCuyiYLIJa9XXNVt1q1jUzHdB+sJvx95VGCpPkCT+IbLecW6yfzy3E1bQrwQ== dependencies: - "@nomicfoundation/ethereumjs-rlp" "^4.0.0-beta.2" + "@chainsafe/ssz" "^0.10.0" + "@nomicfoundation/ethereumjs-rlp" "5.0.2" ethereum-cryptography "0.1.3" -"@nomicfoundation/ethereumjs-vm@^6.0.0-rc.3": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-6.0.0.tgz#2bb50d332bf41790b01a3767ffec3987585d1de6" - integrity sha512-JMPxvPQ3fzD063Sg3Tp+UdwUkVxMoo1uML6KSzFhMH3hoQi/LMuXBoEHAoW83/vyNS9BxEe6jm6LmT5xdeEJ6w== - dependencies: - "@nomicfoundation/ethereumjs-block" "^4.0.0" - "@nomicfoundation/ethereumjs-blockchain" "^6.0.0" - "@nomicfoundation/ethereumjs-common" "^3.0.0" - "@nomicfoundation/ethereumjs-evm" "^1.0.0" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0" - "@nomicfoundation/ethereumjs-statemanager" "^1.0.0" - "@nomicfoundation/ethereumjs-trie" "^5.0.0" - "@nomicfoundation/ethereumjs-tx" "^4.0.0" - "@nomicfoundation/ethereumjs-util" "^8.0.0" - "@types/async-eventemitter" "^0.2.1" - async-eventemitter "^0.2.4" +"@nomicfoundation/ethereumjs-vm@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-7.0.2.tgz#3b0852cb3584df0e18c182d0672a3596c9ca95e6" + integrity sha512-Bj3KZT64j54Tcwr7Qm/0jkeZXJMfdcAtRBedou+Hx0dPOSIgqaIr0vvLwP65TpHbak2DmAq+KJbW2KNtIoFwvA== + 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.3" ethereum-cryptography "0.1.3" - functional-red-black-tree "^1.0.1" mcl-wasm "^0.7.1" rustbn.js "~0.2.0" -"@nomicfoundation/solidity-analyzer-darwin-arm64@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.0.3.tgz#1d49e4ac028831a3011a9f3dca60bd1963185342" - integrity sha512-W+bIiNiZmiy+MTYFZn3nwjyPUO6wfWJ0lnXx2zZrM8xExKObMrhCh50yy8pQING24mHfpPFCn89wEB/iG7vZDw== +"@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz#4c858096b1c17fe58a474fe81b46815f93645c15" + integrity sha512-KcTodaQw8ivDZyF+D76FokN/HdpgGpfjc/gFCImdLUyqB6eSWVaZPazMbeAjmfhx3R0zm/NYVzxwAokFKgrc0w== -"@nomicfoundation/solidity-analyzer-darwin-x64@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-x64/-/solidity-analyzer-darwin-x64-0.0.3.tgz#c0fccecc5506ff5466225e41e65691abafef3dbe" - integrity sha512-HuJd1K+2MgmFIYEpx46uzwEFjvzKAI765mmoMxy4K+Aqq1p+q7hHRlsFU2kx3NB8InwotkkIq3A5FLU1sI1WDw== +"@nomicfoundation/solidity-analyzer-darwin-x64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-x64/-/solidity-analyzer-darwin-x64-0.1.1.tgz#6e25ccdf6e2d22389c35553b64fe6f3fdaec432c" + integrity sha512-XhQG4BaJE6cIbjAVtzGOGbK3sn1BO9W29uhk9J8y8fZF1DYz0Doj8QDMfpMu+A6TjPDs61lbsmeYodIDnfveSA== -"@nomicfoundation/solidity-analyzer-freebsd-x64@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-freebsd-x64/-/solidity-analyzer-freebsd-x64-0.0.3.tgz#8261d033f7172b347490cd005931ef8168ab4d73" - integrity sha512-2cR8JNy23jZaO/vZrsAnWCsO73asU7ylrHIe0fEsXbZYqBP9sMr+/+xP3CELDHJxUbzBY8zqGvQt1ULpyrG+Kw== +"@nomicfoundation/solidity-analyzer-freebsd-x64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-freebsd-x64/-/solidity-analyzer-freebsd-x64-0.1.1.tgz#0a224ea50317139caeebcdedd435c28a039d169c" + integrity sha512-GHF1VKRdHW3G8CndkwdaeLkVBi5A9u2jwtlS7SLhBc8b5U/GcoL39Q+1CSO3hYqePNP+eV5YI7Zgm0ea6kMHoA== -"@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-gnu/-/solidity-analyzer-linux-arm64-gnu-0.0.3.tgz#1ba64b1d76425f8953dedc6367bd7dd46f31dfc5" - integrity sha512-Eyv50EfYbFthoOb0I1568p+eqHGLwEUhYGOxcRNywtlTE9nj+c+MT1LA53HnxD9GsboH4YtOOmJOulrjG7KtbA== +"@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-gnu/-/solidity-analyzer-linux-arm64-gnu-0.1.1.tgz#dfa085d9ffab9efb2e7b383aed3f557f7687ac2b" + integrity sha512-g4Cv2fO37ZsUENQ2vwPnZc2zRenHyAxHcyBjKcjaSmmkKrFr64yvzeNO8S3GBFCo90rfochLs99wFVGT/0owpg== -"@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-musl/-/solidity-analyzer-linux-arm64-musl-0.0.3.tgz#8d864c49b55e683f7e3b5cce9d10b628797280ac" - integrity sha512-V8grDqI+ivNrgwEt2HFdlwqV2/EQbYAdj3hbOvjrA8Qv+nq4h9jhQUxFpegYMDtpU8URJmNNlXgtfucSrAQwtQ== +"@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-musl/-/solidity-analyzer-linux-arm64-musl-0.1.1.tgz#c9e06b5d513dd3ab02a7ac069c160051675889a4" + integrity sha512-WJ3CE5Oek25OGE3WwzK7oaopY8xMw9Lhb0mlYuJl/maZVo+WtP36XoQTb7bW/i8aAdHW5Z+BqrHMux23pvxG3w== -"@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-gnu/-/solidity-analyzer-linux-x64-gnu-0.0.3.tgz#16e769500cf1a8bb42ab9498cee3b93c30f78295" - integrity sha512-uRfVDlxtwT1vIy7MAExWAkRD4r9M79zMG7S09mCrWUn58DbLs7UFl+dZXBX0/8FTGYWHhOT/1Etw1ZpAf5DTrg== +"@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-gnu/-/solidity-analyzer-linux-x64-gnu-0.1.1.tgz#8d328d16839e52571f72f2998c81e46bf320f893" + integrity sha512-5WN7leSr5fkUBBjE4f3wKENUy9HQStu7HmWqbtknfXkkil+eNWiBV275IOlpXku7v3uLsXTOKpnnGHJYI2qsdA== -"@nomicfoundation/solidity-analyzer-linux-x64-musl@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-musl/-/solidity-analyzer-linux-x64-musl-0.0.3.tgz#75f4e1a25526d54c506e4eba63b3d698b6255b8f" - integrity sha512-8HPwYdLbhcPpSwsE0yiU/aZkXV43vlXT2ycH+XlOjWOnLfH8C41z0njK8DHRtEFnp4OVN6E7E5lHBBKDZXCliA== +"@nomicfoundation/solidity-analyzer-linux-x64-musl@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-musl/-/solidity-analyzer-linux-x64-musl-0.1.1.tgz#9b49d0634b5976bb5ed1604a1e1b736f390959bb" + integrity sha512-KdYMkJOq0SYPQMmErv/63CwGwMm5XHenEna9X9aB8mQmhDBrYrlAOSsIPgFCUSL0hjxE3xHP65/EPXR/InD2+w== -"@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-arm64-msvc/-/solidity-analyzer-win32-arm64-msvc-0.0.3.tgz#ef6e20cfad5eedfdb145cc34a44501644cd7d015" - integrity sha512-5WWcT6ZNvfCuxjlpZOY7tdvOqT1kIQYlDF9Q42wMpZ5aTm4PvjdCmFDDmmTvyXEBJ4WTVmY5dWNWaxy8h/E28g== +"@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-arm64-msvc/-/solidity-analyzer-win32-arm64-msvc-0.1.1.tgz#e2867af7264ebbcc3131ef837878955dd6a3676f" + integrity sha512-VFZASBfl4qiBYwW5xeY20exWhmv6ww9sWu/krWSesv3q5hA0o1JuzmPHR4LPN6SUZj5vcqci0O6JOL8BPw+APg== -"@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-ia32-msvc/-/solidity-analyzer-win32-ia32-msvc-0.0.3.tgz#98c4e3af9cee68896220fa7e270aefdf7fc89c7b" - integrity sha512-P/LWGZwWkyjSwkzq6skvS2wRc3gabzAbk6Akqs1/Iiuggql2CqdLBkcYWL5Xfv3haynhL+2jlNkak+v2BTZI4A== +"@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-ia32-msvc/-/solidity-analyzer-win32-ia32-msvc-0.1.1.tgz#0685f78608dd516c8cdfb4896ed451317e559585" + integrity sha512-JnFkYuyCSA70j6Si6cS1A9Gh1aHTEb8kOTBApp/c7NRTFGNMH8eaInKlyuuiIbvYFhlXW4LicqyYuWNNq9hkpQ== -"@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-x64-msvc/-/solidity-analyzer-win32-x64-msvc-0.0.3.tgz#12da288e7ef17ec14848f19c1e8561fed20d231d" - integrity sha512-4AcTtLZG1s/S5mYAIr/sdzywdNwJpOcdStGF3QMBzEt+cGn3MchMaS9b1gyhb2KKM2c39SmPF5fUuWq1oBSQZQ== +"@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-x64-msvc/-/solidity-analyzer-win32-x64-msvc-0.1.1.tgz#c9a44f7108646f083b82e851486e0f6aeb785836" + integrity sha512-HrVJr6+WjIXGnw3Q9u6KQcbZCtk0caVWhCdFADySvRyUxJ8PnzlaP+MhwNE8oyT8OZ6ejHBRrrgjSqDCFXGirw== -"@nomicfoundation/solidity-analyzer@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer/-/solidity-analyzer-0.0.3.tgz#d1029f872e66cb1082503b02cc8b0be12f8dd95e" - integrity sha512-VFMiOQvsw7nx5bFmrmVp2Q9rhIjw2AFST4DYvWVVO9PMHPE23BY2+kyfrQ4J3xCMFC8fcBbGLt7l4q7m1SlTqg== +"@nomicfoundation/solidity-analyzer@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer/-/solidity-analyzer-0.1.1.tgz#f5f4d36d3f66752f59a57e7208cd856f3ddf6f2d" + integrity sha512-1LMtXj1puAxyFusBgUIy5pZk3073cNXYnXUpuNKFghHbIit/xZgbk0AokpUADbNm3gyD6bFWl3LRFh3dhVdREg== optionalDependencies: - "@nomicfoundation/solidity-analyzer-darwin-arm64" "0.0.3" - "@nomicfoundation/solidity-analyzer-darwin-x64" "0.0.3" - "@nomicfoundation/solidity-analyzer-freebsd-x64" "0.0.3" - "@nomicfoundation/solidity-analyzer-linux-arm64-gnu" "0.0.3" - "@nomicfoundation/solidity-analyzer-linux-arm64-musl" "0.0.3" - "@nomicfoundation/solidity-analyzer-linux-x64-gnu" "0.0.3" - "@nomicfoundation/solidity-analyzer-linux-x64-musl" "0.0.3" - "@nomicfoundation/solidity-analyzer-win32-arm64-msvc" "0.0.3" - "@nomicfoundation/solidity-analyzer-win32-ia32-msvc" "0.0.3" - "@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.0.3" + "@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" "@nomiclabs/hardhat-docker@^2.0.0": version "2.0.2" @@ -1646,6 +1757,13 @@ dependencies: antlr4ts "^0.5.0-alpha.4" +"@solidity-parser/parser@^0.16.0": + version "0.16.2" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.16.2.tgz#42cb1e3d88b3e8029b0c9befff00b634cd92d2fa" + integrity sha512-PI9NfoA3P8XK2VBkK5oIfRgKDsicwDZfkVq9ZTBCQYGOP1N2owgY2dyLGyU5/J/hQs8KRk55kdmvTLjy3Mu3vg== + dependencies: + antlr4ts "^0.5.0-alpha.4" + "@szmarczak/http-timer@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" @@ -1832,11 +1950,6 @@ dependencies: fs-extra "^9.1.0" -"@types/async-eventemitter@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@types/async-eventemitter/-/async-eventemitter-0.2.1.tgz#f8e6280e87e8c60b2b938624b0a3530fb3e24712" - integrity sha512-M2P4Ng26QbAeITiH7w1d7OxtldgfAe0wobpyJzVK/XOb0cUGKU2R4pfAhqcJBXAe2ife5ZOhSv4wk7p+ffURtg== - "@types/bignumber.js@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-5.0.0.tgz#d9f1a378509f3010a3255e9cc822ad0eeb4ab969" @@ -2039,6 +2152,14 @@ resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== +"@types/readable-stream@^2.3.13": + version "2.3.15" + resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-2.3.15.tgz#3d79c9ceb1b6a57d5f6e6976f489b9b5384321ae" + integrity sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ== + dependencies: + "@types/node" "*" + safe-buffer "~5.1.1" + "@types/resolve@^0.0.8": version "0.0.8" resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" @@ -2366,6 +2487,41 @@ "@webassemblyjs/ast" "1.11.1" "@xtuc/long" "4.2.2" +"@wry/caches@^1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@wry/caches/-/caches-1.0.1.tgz#8641fd3b6e09230b86ce8b93558d44cf1ece7e52" + integrity sha512-bXuaUNLVVkD20wcGBWRyo7j9N3TxePEWFZj2Y+r9OoUzfqmavM84+mFykRicNsBqatba5JLay1t48wxaXaWnlA== + dependencies: + tslib "^2.3.0" + +"@wry/context@^0.7.0": + version "0.7.4" + resolved "https://registry.yarnpkg.com/@wry/context/-/context-0.7.4.tgz#e32d750fa075955c4ab2cfb8c48095e1d42d5990" + integrity sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ== + dependencies: + tslib "^2.3.0" + +"@wry/equality@^0.5.6": + version "0.5.7" + resolved "https://registry.yarnpkg.com/@wry/equality/-/equality-0.5.7.tgz#72ec1a73760943d439d56b7b1e9985aec5d497bb" + integrity sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw== + dependencies: + tslib "^2.3.0" + +"@wry/trie@^0.4.3": + version "0.4.3" + resolved "https://registry.yarnpkg.com/@wry/trie/-/trie-0.4.3.tgz#077d52c22365871bf3ffcbab8e95cb8bc5689af4" + integrity sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w== + dependencies: + tslib "^2.3.0" + +"@wry/trie@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@wry/trie/-/trie-0.5.0.tgz#11e783f3a53f6e4cd1d42d2d1323f5bc3fa99c94" + integrity sha512-FNoYzHawTMk/6KMQoEG5O4PuioX19UbwdQKF44yw0nLfOypfQdjtfZzo/UIJWAJ23sNIFbD1Ug9lbaDGMwbqQA== + dependencies: + tslib "^2.3.0" + "@xtuc/ieee754@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" @@ -2399,13 +2555,6 @@ abbrev@1.0.x: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" integrity sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q== -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - abortcontroller-polyfill@^1.7.3: version "1.7.3" resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" @@ -2525,7 +2674,7 @@ ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.6.1, ajv@^6.9.1: +ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.12.6, ajv@^6.6.1, ajv@^6.9.1: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -2626,6 +2775,11 @@ antlr4@4.7.1: resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.7.1.tgz#69984014f096e9e775f53dd9744bf994d8959773" integrity sha512-haHyTW7Y9joE5MVs37P2lNYfU2RWBLfcRDD8OWldcdZm5TiCE91B5Xl1oWSwiDUSd4rlExpt2pu1fksYQjRBYQ== +antlr4@^4.11.0: + version "4.13.1" + resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.13.1.tgz#1e0a1830a08faeb86217cb2e6c34716004e4253d" + integrity sha512-kiXTspaRYvnIArgE97z5YVVf/cDVQABr3abFRR6mE7yesLMkgu4ujuyV/sgxafQ8wgve0DJQUJ38Z8tkgA2izA== + antlr4@^4.7.1: version "4.11.0" resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.11.0.tgz#d7466f5044fa6e333c0ec821b30c6157f6b004ae" @@ -2789,7 +2943,7 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw== -ast-parents@0.0.1: +ast-parents@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/ast-parents/-/ast-parents-0.0.1.tgz#508fd0f05d0c48775d9eccda2e174423261e8dd3" integrity sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA== @@ -2804,7 +2958,7 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== -async-eventemitter@^0.2.2, async-eventemitter@^0.2.4: +async-eventemitter@^0.2.2: version "0.2.4" resolved "https://registry.yarnpkg.com/async-eventemitter/-/async-eventemitter-0.2.4.tgz#f5e7c8ca7d3e46aab9ec40a292baf686a0bafaca" integrity sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw== @@ -3957,6 +4111,11 @@ caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001370: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001397.tgz#010d9d56e3b8abcd8df261d0a94b22426271a15f" integrity sha512-SW9N2TbCdLf0eiNDRrrQXx2sOkaakNZbCjgNpPyMJJbiOrU5QzMIrXOVMRM1myBXTD5iTkdrtU/EguCrBocHlA== +case@^1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9" + integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== + caseless@^0.12.0, caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -4383,6 +4542,11 @@ commander@3.0.2: resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== +commander@^10.0.0: + version "10.0.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" + integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== + commander@^2.19.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" @@ -4536,6 +4700,16 @@ cosmiconfig@^5.0.7: js-yaml "^3.13.1" parse-json "^4.0.0" +cosmiconfig@^8.0.0: + version "8.3.6" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" + integrity sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA== + dependencies: + import-fresh "^3.3.0" + js-yaml "^4.1.0" + parse-json "^5.2.0" + path-type "^4.0.0" + crc-32@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff" @@ -6224,6 +6398,42 @@ ethers@^5.0.1, ethers@^5.0.13, ethers@^5.0.2, ethers@^5.5.2, ethers@^5.5.3, ethe "@ethersproject/web" "5.7.0" "@ethersproject/wordlists" "5.7.0" +ethers@^5.7.1: + version "5.7.2" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e" + 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" + ethjs-abi@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/ethjs-abi/-/ethjs-abi-0.2.1.tgz#e0a7a93a7e81163a94477bad56ede524ab6de533" @@ -6249,11 +6459,6 @@ ethjs-util@0.1.6, ethjs-util@^0.1.3, ethjs-util@^0.1.6: is-hex-prefixed "1.0.0" strip-hex-prefix "1.0.0" -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - eventemitter3@4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" @@ -6460,6 +6665,11 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== +fast-diff@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + fast-glob@^3.0.3, fast-glob@^3.2.9: version "3.2.12" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" @@ -7082,6 +7292,17 @@ glob@^7.0.0, glob@^7.1.2, glob@^7.1.3, glob@^7.1.6, glob@~7.2.3: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^8.0.3: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + global-modules@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-2.0.0.tgz#997605ad2345f27f51539bea26574421215c7780" @@ -7225,6 +7446,13 @@ graphql-request@^3.6.1: extract-files "^9.0.0" form-data "^3.0.0" +graphql-tag@^2.12.6: + version "2.12.6" + resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" + integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg== + dependencies: + tslib "^2.1.0" + graphql@15.5.1: version "15.5.1" resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.1.tgz#f2f84415d8985e7b84731e7f3536f8bb9d383aad" @@ -7342,28 +7570,27 @@ hardhat-watcher@^2.1.1: dependencies: chokidar "^3.5.3" -hardhat@2.11.1: - version "2.11.1" - resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.11.1.tgz#9d7967dd360b9a217ac6b7d9ca7f5087db4db01d" - integrity sha512-7FoyfKjBs97GHNpQejHecJBBcRPOEhAE3VkjSWXB3GeeiXefWbw+zhRVOjI4eCsUUt7PyNFAdWje/lhnBT9fig== +hardhat@2.19.4: + version "2.19.4" + resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.19.4.tgz#5112c30295d8be2e18e55d847373c50483ed1902" + integrity sha512-fTQJpqSt3Xo9Mn/WrdblNGAfcANM6XC3tAEi6YogB4s02DmTf93A8QsGb8uR0KR8TFcpcS8lgiW4ugAIYpnbrQ== dependencies: "@ethersproject/abi" "^5.1.2" "@metamask/eth-sig-util" "^4.0.0" - "@nomicfoundation/ethereumjs-block" "^4.0.0-rc.3" - "@nomicfoundation/ethereumjs-blockchain" "^6.0.0-rc.3" - "@nomicfoundation/ethereumjs-common" "^3.0.0-rc.3" - "@nomicfoundation/ethereumjs-evm" "^1.0.0-rc.3" - "@nomicfoundation/ethereumjs-rlp" "^4.0.0-rc.3" - "@nomicfoundation/ethereumjs-statemanager" "^1.0.0-rc.3" - "@nomicfoundation/ethereumjs-trie" "^5.0.0-rc.3" - "@nomicfoundation/ethereumjs-tx" "^4.0.0-rc.3" - "@nomicfoundation/ethereumjs-util" "^8.0.0-rc.3" - "@nomicfoundation/ethereumjs-vm" "^6.0.0-rc.3" - "@nomicfoundation/solidity-analyzer" "^0.0.3" + "@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.0" "@sentry/node" "^5.18.1" "@types/bn.js" "^5.1.0" "@types/lru-cache" "^5.1.0" - abort-controller "^3.0.0" adm-zip "^0.4.16" aggregate-error "^3.0.0" ansi-escapes "^4.3.0" @@ -7386,7 +7613,6 @@ hardhat@2.11.1: mnemonist "^0.38.0" mocha "^10.0.0" p-map "^4.0.0" - qs "^6.7.0" raw-body "^2.4.1" resolve "1.17.0" semver "^6.3.0" @@ -7394,7 +7620,7 @@ hardhat@2.11.1: source-map-support "^0.5.13" stacktrace-parser "^0.1.10" tsort "0.0.1" - undici "^5.4.0" + undici "^5.14.0" uuid "^8.3.2" ws "^7.4.6" @@ -7554,6 +7780,13 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +hoist-non-react-statics@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + home-or-tmp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -7745,6 +7978,11 @@ ignore@^5.1.1, ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== +ignore@^5.2.4: + version "5.3.1" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" + integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== + immediate@^3.2.3: version "3.3.0" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" @@ -7768,7 +8006,7 @@ import-fresh@^2.0.0: caller-path "^2.0.0" resolve-from "^3.0.0" -import-fresh@^3.0.0, import-fresh@^3.2.1: +import-fresh@^3.0.0, import-fresh@^3.2.1, import-fresh@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -8246,6 +8484,11 @@ jest-worker@^27.4.5: merge-stream "^2.0.0" supports-color "^8.0.0" +js-sdsl@^4.1.4: + version "4.4.2" + resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.4.2.tgz#2e3c031b1f47d3aca8b775532e3ebb0818e7f847" + integrity sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w== + js-sha3@0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.5.tgz#baf0c0e8c54ad5903447df96ade7a4a1bca79a4a" @@ -8287,7 +8530,7 @@ js-yaml@3.x, js-yaml@^3.12.0, js-yaml@^3.13.0, js-yaml@^3.13.1, js-yaml@^3.14.0: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@4.1.0: +js-yaml@4.1.0, js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== @@ -8334,7 +8577,7 @@ json-parse-better-errors@^1.0.1: resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== -json-parse-even-better-errors@^2.3.1: +json-parse-even-better-errors@^2.3.0, json-parse-even-better-errors@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== @@ -8729,6 +8972,11 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== + load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" @@ -8854,7 +9102,7 @@ looper@^3.0.0: resolved "https://registry.yarnpkg.com/looper/-/looper-3.0.0.tgz#2efa54c3b1cbaba9b94aee2e5914b0be57fbb749" integrity sha512-LJ9wplN/uSn72oJRsXTx+snxPet5c8XiZmOKCm906NVYu+ag6SB6vUcnJcWxgnl2NfbIyeobAn7Bwv6xRj2XJg== -loose-envify@^1.0.0: +loose-envify@^1.0.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== @@ -9233,6 +9481,13 @@ minimatch@5.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@^5.0.1: + version "5.1.6" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" + integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@~1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" @@ -9856,6 +10111,16 @@ open@^7.4.2: is-docker "^2.0.0" is-wsl "^2.1.1" +optimism@^0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/optimism/-/optimism-0.18.0.tgz#e7bb38b24715f3fdad8a9a7fc18e999144bbfa63" + integrity sha512-tGn8+REwLRNFnb9WmcY5IfpOqeX2kpaYJ1s6Ae3mn12AeydLkR3j+jSCmVQFoXqU8D41PAJ1RG1rCRNWmNZVmQ== + dependencies: + "@wry/caches" "^1.0.0" + "@wry/context" "^0.7.0" + "@wry/trie" "^0.4.3" + tslib "^2.3.0" + optionator@^0.8.1, optionator@^0.8.2: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" @@ -10065,6 +10330,16 @@ parse-json@^4.0.0: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" +parse-json@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== + dependencies: + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" + parse5-htmlparser2-tree-adapter@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz#23c2cc233bcf09bb7beba8b8a69d46b08c62c2f1" @@ -10298,6 +10573,11 @@ pkg-up@^2.0.0: dependencies: find-up "^2.1.0" +pluralize@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" + integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA== + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" @@ -10420,6 +10700,11 @@ prettier@^1.14.3: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@^2.8.3: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== + pretty-error@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-4.0.0.tgz#90a703f46dd7234adb46d0f84823e9d1cb8f10d6" @@ -10463,6 +10748,15 @@ promise@^8.0.0: dependencies: asap "~2.0.6" +prop-types@^15.7.2: + version "15.8.1" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" + integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== + dependencies: + loose-envify "^1.4.0" + object-assign "^4.1.1" + react-is "^16.13.1" + proper-lockfile@^4.1.1: version "4.1.2" resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f" @@ -10603,7 +10897,7 @@ qs@6.7.0: resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== -qs@^6.4.0, qs@^6.7.0, qs@^6.9.4: +qs@^6.4.0, qs@^6.9.4: version "6.11.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== @@ -10684,6 +10978,11 @@ raw-body@2.5.1, raw-body@^2.4.1: iconv-lite "0.4.24" unpipe "1.0.0" +react-is@^16.13.1, react-is@^16.7.0: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -11025,6 +11324,11 @@ resolve@^1.1.6, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.20.0, resolve@^1.8. path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +response-iterator@^0.2.6: + version "0.2.6" + resolved "https://registry.yarnpkg.com/response-iterator/-/response-iterator-0.2.6.tgz#249005fb14d2e4eeb478a3f735a28fd8b4c9f3da" + integrity sha512-pVzEEzrsg23Sh053rmDUvLSkGXluZio0qu8VT6ukrYuvtjVfCbDZH9d6PGXb8HZfzdNZt8feXv/jvUzlhRgLnw== + responselike@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" @@ -11252,6 +11556,11 @@ semver@^6.1.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.5.2: + version "7.6.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" + integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== + semver@~5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" @@ -11595,27 +11904,30 @@ solhint-plugin-prettier@0.0.5: dependencies: prettier-linter-helpers "^1.0.0" -solhint@3.3.6: - version "3.3.6" - resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.3.6.tgz#abe9af185a9a7defefba480047b3e42cbe9a1210" - integrity sha512-HWUxTAv2h7hx3s3hAab3ifnlwb02ZWhwFU/wSudUHqteMS3ll9c+m1FlGn9V8ztE2rf3Z82fQZA005Wv7KpcFA== +solhint@3.6.2: + version "3.6.2" + resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.6.2.tgz#2b2acbec8fdc37b2c68206a71ba89c7f519943fe" + integrity sha512-85EeLbmkcPwD+3JR7aEMKsVC9YrRSxd4qkXuMzrlf7+z2Eqdfm1wHWq1ffTuo5aDhoZxp2I9yF3QkxZOxOL7aQ== dependencies: - "@solidity-parser/parser" "^0.13.2" - ajv "^6.6.1" - antlr4 "4.7.1" - ast-parents "0.0.1" - chalk "^2.4.2" - commander "2.18.0" - cosmiconfig "^5.0.7" - eslint "^5.6.0" - fast-diff "^1.1.2" - glob "^7.1.3" - ignore "^4.0.6" - js-yaml "^3.12.0" - lodash "^4.17.11" - semver "^6.3.0" + "@solidity-parser/parser" "^0.16.0" + ajv "^6.12.6" + antlr4 "^4.11.0" + ast-parents "^0.0.1" + chalk "^4.1.2" + commander "^10.0.0" + cosmiconfig "^8.0.0" + fast-diff "^1.2.0" + glob "^8.0.3" + ignore "^5.2.4" + js-yaml "^4.1.0" + lodash "^4.17.21" + pluralize "^8.0.0" + semver "^7.5.2" + strip-ansi "^6.0.1" + table "^6.8.1" + text-table "^0.2.0" optionalDependencies: - prettier "^1.14.3" + prettier "^2.8.3" solhint@^2.0.0: version "2.3.1" @@ -12091,6 +12403,11 @@ swarm-js@^0.1.40: tar "^4.0.2" xhr-request "^1.0.1" +symbol-observable@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-4.0.0.tgz#5b425f192279e87f2f9b937ac8540d1984b39205" + integrity sha512-b19dMThMV4HVFynSAM1++gBHAbk2Tc/osgLIBZMKsyqh34jb2e8Os7T6ZW/Bt3pJFdBTd2JwAnAAEQV7rSNvcQ== + sync-request@^6.0.0: version "6.1.0" resolved "https://registry.yarnpkg.com/sync-request/-/sync-request-6.1.0.tgz#e96217565b5e50bbffe179868ba75532fb597e68" @@ -12138,6 +12455,17 @@ table@^6.0.9, table@^6.8.0: string-width "^4.2.3" strip-ansi "^6.0.1" +table@^6.8.1: + version "6.8.2" + resolved "https://registry.yarnpkg.com/table/-/table-6.8.2.tgz#c5504ccf201213fa227248bdc8c5569716ac6c58" + integrity sha512-w2sfv80nrAh2VCbqR5AK27wswXhqcck2AhfnNW76beQXskGZ1V12GwS//yYVa3d3fcvAip2OUnbDAjW2k3v9fA== + dependencies: + ajv "^8.0.1" + lodash.truncate "^4.4.2" + slice-ansi "^4.0.0" + string-width "^4.2.3" + strip-ansi "^6.0.1" + tapable@^2.0.0, tapable@^2.1.1, tapable@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" @@ -12445,6 +12773,13 @@ ts-generator@^0.1.1: resolve "^1.8.1" ts-essentials "^1.0.0" +ts-invariant@^0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/ts-invariant/-/ts-invariant-0.10.3.tgz#3e048ff96e91459ffca01304dbc7f61c1f642f6c" + integrity sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ== + dependencies: + tslib "^2.1.0" + ts-node@10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.1.0.tgz#e656d8ad3b61106938a867f69c39a8ba6efc966e" @@ -12481,6 +12816,11 @@ tslib@^2.0.0, tslib@^2.0.3, tslib@^2.3.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@^2.1.0, tslib@^2.3.0: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tsort@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tsort/-/tsort-0.0.1.tgz#e2280f5e817f8bf4275657fd0f9aebd44f5a2786" @@ -12596,10 +12936,10 @@ typechain@^3.0.0: ts-essentials "^6.0.3" ts-generator "^0.1.1" -typechain@^8.0.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.1.0.tgz#fc4902ce596519cb2ccfd012e4ddf92a9945b569" - integrity sha512-5jToLgKTjHdI1VKqs/K8BLYy42Sr3o8bV5ojh4MnR9ExHO83cyyUdw+7+vMJCpKXUiVUvARM4qmHTFuyaCMAZQ== +typechain@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.2.tgz#1090dd8d9c57b6ef2aed3640a516bdbf01b00d73" + integrity sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q== dependencies: "@types/prettier" "^2.1.1" debug "^4.3.1" @@ -12691,6 +13031,13 @@ underscore@^1.8.3: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.4.tgz#7886b46bbdf07f768e0052f1828e1dcab40c0dee" integrity sha512-BQFnUDuAQ4Yf/cYY5LNrK9NCJFKriaRbD9uR1fTeXnBeoa97W0i41qkZfGO9pSo8I5KzjAcSY2XYtdf0oKd7KQ== +undici@^5.14.0: + version "5.28.2" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.2.tgz#fea200eac65fc7ecaff80a023d1a0543423b4c91" + integrity sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w== + dependencies: + "@fastify/busboy" "^2.0.0" + undici@^5.4.0: version "5.10.0" resolved "https://registry.yarnpkg.com/undici/-/undici-5.10.0.tgz#dd9391087a90ccfbd007568db458674232ebf014" @@ -14178,6 +14525,18 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== +zen-observable-ts@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/zen-observable-ts/-/zen-observable-ts-1.2.5.tgz#6c6d9ea3d3a842812c6e9519209365a122ba8b58" + integrity sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg== + dependencies: + zen-observable "0.8.15" + +zen-observable@0.8.15: + version "0.8.15" + resolved "https://registry.yarnpkg.com/zen-observable/-/zen-observable-0.8.15.tgz#96415c512d8e3ffd920afd3889604e30b9eaac15" + integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== + zksync-web3@^0.7.8: version "0.7.13" resolved "https://registry.yarnpkg.com/zksync-web3/-/zksync-web3-0.7.13.tgz#9d87cfeac8a38e0c5702c2e05f80e50215d1102d"