From c108bfbec249938137dacbca026b86063777c6d4 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:06:13 +0100 Subject: [PATCH 01/12] feature: update generatePath function, deploy and verify file to be chain agnostic --- .env.example | 4 +- .github/workflows/ci.yml | 4 +- contracts/OffsetHelper.sol | 566 ++++++++++++++++++------------ contracts/OffsetHelperStorage.sol | 13 +- deploy/00_deploy_offsetHelper.ts | 26 +- hardhat.config.ts | 12 +- tasks/verifyOffsetHelper.ts | 12 +- 7 files changed, 384 insertions(+), 253 deletions(-) diff --git a/.env.example b/.env.example index 985bf81..a0aaa19 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ -POLYGON_URL=https://matic-mainnet.chainstacklabs.com +RPC_ENDPOINT=https://forno.celo.org PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -POLYGONSCAN_KEY=abc123abc123abc123abc123abc123abc123abc +BLOCK_EXPLORER_API_KEY=B591PTIWMCIK4AJHVHZ8PYYA9E72EAA7UG diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 434d91e..794d4e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: - name: Test contract run: yarn test env: - POLYGON_URL: ${{ secrets.POLYGON_URL }} + RPC_ENDPOINT: ${{ secrets.RPC_ENDPOINT }} - name: Test solidity-docgen builds run: yarn doc @@ -67,4 +67,4 @@ jobs: - name: Deploy contract run: yarn hardhat deploy --network hardhat env: - POLYGON_URL: ${{ secrets.POLYGON_URL }} + RPC_ENDPOINT: ${{ secrets.RPC_ENDPOINT }} diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 103d50c..0274438 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -1,5 +1,4 @@ // SPDX-FileCopyrightText: 2022 Toucan Labs -// // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; @@ -18,24 +17,24 @@ import "./interfaces/IToucanContractRegistry.sol"; * * Retiring carbon tokens requires multiple steps and interactions with * Toucan Protocol's main contracts: - * 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token - * swap). + * 1. Obtain a Toucan pool token e.g., NCT (by performing a token + * swap on a DEX). * 2. Redeem the pool token for a TCO2 token. * 3. Retire the TCO2 token. * * These steps are combined in each of the following "auto offset" methods * implemented in `OffsetHelper` to allow a retirement within one transaction: * - `autoOffsetPoolToken()` if the user already owns a Toucan pool - * token such as BCT or NCT, + * token e.g., NCT, * - `autoOffsetExactOutETH()` if the user would like to perform a retirement - * using MATIC, specifying the exact amount of TCO2s to retire, + * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), * - `autoOffsetExactInETH()` if the user would like to perform a retirement - * using MATIC, swapping all sent MATIC into TCO2s, + * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), * - `autoOffsetExactOutToken()` if the user would like to perform a retirement - * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount + * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount * of TCO2s to retire, * - `autoOffsetExactInToken()` if the user would like to perform a retirement - * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount + * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount * of token to swap into TCO2s. * * In these methods, "auto" refers to the fact that these methods use @@ -47,7 +46,7 @@ import "./interfaces/IToucanContractRegistry.sol"; * There are two `view` helper functions `calculateNeededETHAmount()` and * `calculateNeededTokenAmount()` that should be called before using * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how - * much MATIC, respectively how much of the ERC20 token must be sent to the + * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the * `OffsetHelper` contract in order to retire the specified amount of carbon. * * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and @@ -58,44 +57,18 @@ import "./interfaces/IToucanContractRegistry.sol"; contract OffsetHelper is OffsetHelperStorage { using SafeERC20 for IERC20; - /** - * @notice Contract constructor. Should specify arrays of ERC20 symbols and - * addresses that can used by the contract. - * - * @dev See `isEligible()` for a list of tokens that can be used in the - * contract. These can be modified after deployment by the contract owner - * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`. - * - * @param _eligibleTokenSymbols A list of token symbols. - * @param _eligibleTokenAddresses A list of token addresses corresponding - * to the provided token symbols. - */ - constructor( - string[] memory _eligibleTokenSymbols, - address[] memory _eligibleTokenAddresses - ) { - uint256 i = 0; - uint256 eligibleTokenSymbolsLen = _eligibleTokenSymbols.length; - while (i < eligibleTokenSymbolsLen) { - eligibleTokenAddresses[ - _eligibleTokenSymbols[i] - ] = _eligibleTokenAddresses[i]; - i += 1; - } - } - /** * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan - * pool token such as BCT or NCT. + * pool token e.g., NCT. * - * @param who The sender of the transaction + * @param sender The sender of the transaction * @param poolToken The address of the Toucan pool token used in the - * redemption, for example, NCT or BCT + * redemption, e.g., NCT * @param tco2s An array of the TCO2 addresses that were redeemed * @param amounts An array of the amounts of each TCO2 that were redeemed */ event Redeemed( - address who, + address sender, address poolToken, address[] tco2s, uint256[] amounts @@ -108,15 +81,46 @@ contract OffsetHelper is OffsetHelperStorage { } modifier onlySwappable(address _token) { - require(isSwappable(_token), "Token not swappable"); + require(isSwappable(_token), "Path doesn't yet exists."); _; } + /** + * @notice Contract constructor. Should specify arrays of ERC20 symbols and + * addresses that can used by the contract. + * + * @dev See `isEligible()` for a list of tokens that can be used in the + * contract. These can be modified after deployment by the contract owner + * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`. + * + * @param _poolAddresses A list of pool token addresses. + * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for + * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token + * to the provided token symbols. + */ + constructor( + address[] memory _poolAddresses, + string[] memory _tokenSymbolsForPaths, + address[][] memory _paths + ) { + poolAddresses = _poolAddresses; + tokenSymbolsForPaths = _tokenSymbolsForPaths; + paths = _paths; + + uint256 i = 0; + uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length; + while (i < eligibleSwapPathsBySymbolLen) { + eligibleSwapPaths[_paths[i][0]] = _paths[i]; + eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i]; + i += 1; + } + } + /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 * tokens available from the specified Toucan token pool by sending ERC20 - * tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in + * tokens (cUSD, USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in * order to find out how much of the ERC20 token is required to retire the * specified quantity of TCO2. * @@ -131,22 +135,22 @@ contract OffsetHelper is OffsetHelperStorage { * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool * token. * - * @param _depositedToken The address of the ERC20 token that the user sends - * (must be one of USDC, WETH, WMATIC) + * @param _fromToken The address of the ERC20 token that the user sends + * (e.g., cUSD, cUSD, USDC, WETH, WMATIC) * @param _poolToken The address of the Toucan pool token that the - * user wants to use, for example, NCT or BCT + * user wants to use, e.g., NCT * @param _amountToOffset The amount of TCO2 to offset * * @return tco2s An array of the TCO2 addresses that were redeemed * @return amounts An array of the amounts of each TCO2 that were redeemed */ function autoOffsetExactOutToken( - address _depositedToken, + address _fromToken, address _poolToken, uint256 _amountToOffset ) public returns (address[] memory tco2s, uint256[] memory amounts) { // swap input token for BCT / NCT - swapExactOutToken(_depositedToken, _poolToken, _amountToOffset); + swapExactOutToken(_fromToken, _poolToken, _amountToOffset); // redeem BCT / NCT for TCO2s (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset); @@ -158,7 +162,7 @@ contract OffsetHelper is OffsetHelperStorage { /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 * tokens available from the specified Toucan token pool by sending ERC20 - * tokens (USDC, WETH, WMATIC). All provided token is consumed for + * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for * offsetting. * * This function: @@ -173,22 +177,26 @@ contract OffsetHelper is OffsetHelperStorage { * token. * * @param _fromToken The address of the ERC20 token that the user sends - * (must be one of USDC, WETH, WMATIC) + * (e.g., cUSD, cUSD, USDC, WETH, WMATIC) + * @param _poolToken The address of the Toucan pool token that the + * user wants to use, e.g., NCT * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool * token. Full amount will be used for offsetting. - * @param _poolToken The address of the Toucan pool token that the - * user wants to use, for example, NCT or BCT * * @return tco2s An array of the TCO2 addresses that were redeemed * @return amounts An array of the amounts of each TCO2 that were redeemed */ function autoOffsetExactInToken( address _fromToken, - uint256 _amountToSwap, - address _poolToken + address _poolToken, + uint256 _amountToSwap ) public returns (address[] memory tco2s, uint256[] memory amounts) { // swap input token for BCT / NCT - uint256 amountToOffset = swapExactInToken(_fromToken, _amountToSwap, _poolToken); + uint256 amountToOffset = swapExactInToken( + _fromToken, + _poolToken, + _amountToSwap + ); // redeem BCT / NCT for TCO2s (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset); @@ -199,31 +207,34 @@ contract OffsetHelper is OffsetHelperStorage { /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 - * tokens available from the specified Toucan token pool by sending MATIC. + * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. * Use `calculateNeededETHAmount()` first in order to find out how much - * MATIC is required to retire the specified quantity of TCO2. + * native tokens are required to retire the specified quantity of TCO2. * * This function: * 1. Swaps the Matic sent to the contract for the specified pool token. * 2. Redeems the pool token for the poorest quality TCO2 tokens available. * 3. Retires the TCO2 tokens. * - * @dev If the user sends much MATIC, the leftover amount will be sent back - * to the user. + * @dev If the user sends too much native tokens , the leftover amount will be sent back + * to the user. This function is only available on Polygon, not on Celo. * - * @param _poolToken The address of the Toucan pool token that the - * user wants to use, for example, NCT or BCT. + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @param _amountToOffset The amount of TCO2 to offset. * * @return tco2s An array of the TCO2 addresses that were redeemed * @return amounts An array of the amounts of each TCO2 that were redeemed */ - function autoOffsetExactOutETH(address _poolToken, uint256 _amountToOffset) + function autoOffsetExactOutETH( + address _poolToken, + uint256 _amountToOffset + ) public payable returns (address[] memory tco2s, uint256[] memory amounts) { - // swap MATIC for BCT / NCT + // swap native tokens for BCT / NCT swapExactOutETH(_poolToken, _amountToOffset); // redeem BCT / NCT for TCO2s @@ -235,26 +246,30 @@ contract OffsetHelper is OffsetHelperStorage { /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 - * tokens available from the specified Toucan token pool by sending MATIC. - * All provided MATIC is consumed for offsetting. + * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. + * All provided native tokens is consumed for offsetting. * * This function: * 1. Swaps the Matic sent to the contract for the specified pool token. * 2. Redeems the pool token for the poorest quality TCO2 tokens available. * 3. Retires the TCO2 tokens. * - * @param _poolToken The address of the Toucan pool token that the - * user wants to use, for example, NCT or BCT. + * @dev This function is only available on Polygon, not on Celo. + * + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * * @return tco2s An array of the TCO2 addresses that were redeemed * @return amounts An array of the amounts of each TCO2 that were redeemed */ - function autoOffsetExactInETH(address _poolToken) + function autoOffsetExactInETH( + address _poolToken + ) public payable returns (address[] memory tco2s, uint256[] memory amounts) { - // swap MATIC for BCT / NCT + // swap native tokens for BCT / NCT uint256 amountToOffset = swapExactInETH(_poolToken); // redeem BCT / NCT for TCO2s @@ -266,7 +281,7 @@ contract OffsetHelper is OffsetHelperStorage { /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 - * tokens available by sending Toucan pool tokens, for example, BCT or NCT. + * tokens available by sending Toucan pool tokens, e.g., NCT. * * This function: * 1. Redeems the pool token for the poorest quality TCO2 tokens available. @@ -274,8 +289,8 @@ contract OffsetHelper is OffsetHelperStorage { * * Note: The client must approve the pool token that is sent. * - * @param _poolToken The address of the Toucan pool token that the - * user wants to use, for example, NCT or BCT. + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @param _amountToOffset The amount of TCO2 to offset. * * @return tco2s An array of the TCO2 addresses that were redeemed @@ -296,19 +311,17 @@ contract OffsetHelper is OffsetHelperStorage { } /** - * @notice Checks whether an address can be used by the contract. - * @param _erc20Address address of the ERC20 token to be checked - * @return True if the address can be used by the contract + * @notice Checks whether an address is a Toucan pool token address + * @param _erc20Address address of token to be checked + * @return True if the address is a Toucan pool token address */ - function isEligible(address _erc20Address) private view returns (bool) { - bool isToucanContract = IToucanContractRegistry(contractRegistryAddress) - .checkERC20(_erc20Address); - if (isToucanContract) return true; - if (_erc20Address == eligibleTokenAddresses["BCT"]) return true; - if (_erc20Address == eligibleTokenAddresses["NCT"]) return true; - if (_erc20Address == eligibleTokenAddresses["USDC"]) return true; - if (_erc20Address == eligibleTokenAddresses["WETH"]) return true; - if (_erc20Address == eligibleTokenAddresses["WMATIC"]) return true; + function isRedeemable(address _erc20Address) private view returns (bool) { + for (uint i = 0; i < poolAddresses.length; i++) { + if (poolAddresses[i] == _erc20Address) { + return true; + } + } + return false; } @@ -318,42 +331,43 @@ contract OffsetHelper is OffsetHelperStorage { * @return True if the specified address can be used in a swap */ function isSwappable(address _erc20Address) private view returns (bool) { - if (_erc20Address == eligibleTokenAddresses["USDC"]) return true; - if (_erc20Address == eligibleTokenAddresses["WETH"]) return true; - if (_erc20Address == eligibleTokenAddresses["WMATIC"]) return true; - return false; - } + for (uint i = 0; i < paths.length; i++) { + if (paths[i][0] == _erc20Address) { + return true; + } + } - /** - * @notice Checks whether an address is a Toucan pool token address - * @param _erc20Address address of token to be checked - * @return True if the address is a Toucan pool token address - */ - function isRedeemable(address _erc20Address) private view returns (bool) { - if (_erc20Address == eligibleTokenAddresses["BCT"]) return true; - if (_erc20Address == eligibleTokenAddresses["NCT"]) return true; return false; } /** * @notice Return how much of the specified ERC20 token is required in * order to swap for the desired amount of a Toucan pool token, for - * example, BCT or NCT. + * example, e.g., NCT. * * @param _fromToken The address of the ERC20 token used for the swap - * @param _toToken The address of the pool token to swap for, - * for example, NCT or BCT + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @param _toAmount The desired amount of pool token to receive * @return amountsIn The amount of the ERC20 token required in order to * swap for the specified amount of the pool token */ function calculateNeededTokenAmount( address _fromToken, - address _toToken, + address _poolToken, uint256 _toAmount - ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) { - (, uint256[] memory amounts) = - calculateExactOutSwap(_fromToken, _toToken, _toAmount); + ) + public + view + onlySwappable(_fromToken) + onlyRedeemable(_poolToken) + returns (uint256) + { + (, uint256[] memory amounts) = calculateExactOutSwap( + _fromToken, + _poolToken, + _toAmount + ); return amounts[0]; } @@ -362,36 +376,48 @@ contract OffsetHelper is OffsetHelperStorage { * acquired by swapping the provided amount of ERC20 token. * * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @param _fromAmount The amount of ERC20 token to swap - * @param _toToken The address of the pool token to swap for, - * for example, NCT or BCT * @return The expected amount of Pool token that can be acquired */ function calculateExpectedPoolTokenForToken( address _fromToken, - uint256 _fromAmount, - address _toToken - ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) { - (, uint256[] memory amounts) = - calculateExactInSwap(_fromToken, _fromAmount, _toToken); + address _poolToken, + uint256 _fromAmount + ) + public + view + onlySwappable(_fromToken) + onlyRedeemable(_poolToken) + returns (uint256) + { + (, uint256[] memory amounts) = calculateExactInSwap( + _fromToken, + _poolToken, + _fromAmount + ); return amounts[amounts.length - 1]; } /** * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap * @dev Needs to be approved on the client side - * @param _fromToken The ERC20 oken to deposit and swap - * @param _toToken The token to swap for (will be held within contract) + * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @param _toAmount The required amount of the Toucan pool token (NCT/BCT) */ function swapExactOutToken( address _fromToken, - address _toToken, + address _poolToken, uint256 _toAmount - ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) { + ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) { // calculate path & amounts - (address[] memory path, uint256[] memory expAmounts) = - calculateExactOutSwap(_fromToken, _toToken, _toAmount); + ( + address[] memory path, + uint256[] memory expAmounts + ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount); uint256 amountIn = expAmounts[0]; // transfer tokens @@ -402,10 +428,10 @@ contract OffsetHelper is OffsetHelperStorage { ); // approve router - IERC20(_fromToken).approve(sushiRouterAddress, amountIn); + IERC20(_fromToken).approve(dexRouterAddress, amountIn); // swap - uint256[] memory amounts = routerSushi().swapTokensForExactTokens( + uint256[] memory amounts = dexRouter().swapTokensForExactTokens( _toAmount, amountIn, // max. input amount path, @@ -415,30 +441,38 @@ contract OffsetHelper is OffsetHelperStorage { // remove remaining approval if less input token was consumed if (amounts[0] < amountIn) { - IERC20(_fromToken).approve(sushiRouterAddress, 0); + IERC20(_fromToken).approve(dexRouterAddress, 0); } // update balances - balances[msg.sender][_toToken] += _toAmount; + balances[msg.sender][_poolToken] += _toAmount; } /** * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on * SushiSwap. All provided ERC20 tokens will be swapped. * @dev Needs to be approved on the client side. - * @param _fromToken The ERC20 token to deposit and swap + * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, * @param _fromAmount The amount of ERC20 token to swap - * @param _toToken The Toucan token to swap for (will be held within contract) + * e.g., NCT * @return Resulting amount of Toucan pool token that got acquired for the * swapped ERC20 tokens. */ function swapExactInToken( address _fromToken, - uint256 _fromAmount, - address _toToken - ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) { + address _poolToken, + uint256 _fromAmount + ) + public + onlySwappable(_fromToken) + onlyRedeemable(_poolToken) + returns (uint256) + { // calculate path & amounts - address[] memory path = generatePath(_fromToken, _toToken); + + address[] memory path = generatePath(_fromToken, _poolToken); + uint256 len = path.length; // transfer tokens @@ -449,10 +483,10 @@ contract OffsetHelper is OffsetHelperStorage { ); // approve router - IERC20(_fromToken).safeApprove(sushiRouterAddress, _fromAmount); + IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount); // swap - uint256[] memory amounts = routerSushi().swapExactTokensForTokens( + uint256[] memory amounts = dexRouter().swapExactTokensForTokens( _fromAmount, 0, // min. output amount path, @@ -462,71 +496,77 @@ contract OffsetHelper is OffsetHelperStorage { uint256 amountOut = amounts[len - 1]; // update balances - balances[msg.sender][_toToken] += amountOut; + balances[msg.sender][_poolToken] += amountOut; return amountOut; } - // apparently I need a fallback and a receive method to fix the situation where transfering dust MATIC - // in the MATIC to token swap fails + // apparently I need a fallback and a receive method to fix the situation where transfering dust native tokens + // in the native tokens to token swap fails fallback() external payable {} - receive() external payable {} - /** - * @notice Return how much MATIC is required in order to swap for the - * desired amount of a Toucan pool token, for example, BCT or NCT. - * - * @param _toToken The address of the pool token to swap for, for - * example, NCT or BCT + * @notice Return how much native tokens e.g, MATIC is required in order to swap for the + * desired amount of a Toucan pool token, e.g., NCT. + * @param _poolToken The address of the pool token to swap for, for + * example, NCT * @param _toAmount The desired amount of pool token to receive - * @return amounts The amount of MATIC required in order to swap for + * @return amounts The amount of native tokens required in order to swap for * the specified amount of the pool token */ - function calculateNeededETHAmount(address _toToken, uint256 _toAmount) - public - view - onlyRedeemable(_toToken) - returns (uint256) - { - address fromToken = eligibleTokenAddresses["WMATIC"]; - (, uint256[] memory amounts) = - calculateExactOutSwap(fromToken, _toToken, _toAmount); + function calculateNeededETHAmount( + address _poolToken, + uint256 _toAmount + ) public view onlyRedeemable(_poolToken) returns (uint256) { + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + (, uint256[] memory amounts) = calculateExactOutSwap( + fromToken, + _poolToken, + _toAmount + ); return amounts[0]; } /** * @notice Calculates the expected amount of Toucan Pool token that can be - * acquired by swapping the provided amount of MATIC. + * acquired by swapping the provided amount of native tokens e.g., MATIC. * - * @param _fromMaticAmount The amount of MATIC to swap - * @param _toToken The address of the pool token to swap for, - * for example, NCT or BCT + * @param _fromTokenAmount The amount of native tokens to swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @return The expected amount of Pool token that can be acquired */ function calculateExpectedPoolTokenForETH( - uint256 _fromMaticAmount, - address _toToken - ) public view onlyRedeemable(_toToken) returns (uint256) { - address fromToken = eligibleTokenAddresses["WMATIC"]; - (, uint256[] memory amounts) = - calculateExactInSwap(fromToken, _fromMaticAmount, _toToken); + address _poolToken, + uint256 _fromTokenAmount + ) public view onlyRedeemable(_poolToken) returns (uint256) { + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + (, uint256[] memory amounts) = calculateExactInSwap( + fromToken, + _poolToken, + _fromTokenAmount + ); return amounts[amounts.length - 1]; } /** - * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. - * Remaining MATIC that was not consumed by the swap is returned. - * @param _toToken Token to swap for (will be held within contract) - * @param _toAmount Amount of NCT / BCT wanted + * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. + * Remaining native tokens that was not consumed by the swap is returned. + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT + * @param _toAmount The required amount of the Toucan pool token (NCT/BCT) */ - function swapExactOutETH(address _toToken, uint256 _toAmount) public payable onlyRedeemable(_toToken) { - // calculate path & amounts - address fromToken = eligibleTokenAddresses["WMATIC"]; - address[] memory path = generatePath(fromToken, _toToken); + function swapExactOutETH( + address _poolToken, + uint256 _toAmount + ) public payable onlyRedeemable(_poolToken) { + // create path & amounts + // wrap the native token + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + address[] memory path = generatePath(fromToken, _poolToken); // swap - uint256[] memory amounts = routerSushi().swapETHForExactTokens{ + uint256[] memory amounts = dexRouter().swapETHForExactTokens{ value: msg.value }(_toAmount, path, address(this), block.timestamp); @@ -541,31 +581,36 @@ contract OffsetHelper is OffsetHelperStorage { } // update balances - balances[msg.sender][_toToken] += _toAmount; + balances[msg.sender][_poolToken] += _toAmount; } /** - * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All - * provided MATIC will be swapped. - * @param _toToken Token to swap for (will be held within contract) + * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All + * provided native tokens will be swapped. + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT * @return Resulting amount of Toucan pool token that got acquired for the - * swapped MATIC. + * swapped native tokens . */ - function swapExactInETH(address _toToken) public payable onlyRedeemable(_toToken) returns (uint256) { - // calculate path & amounts + function swapExactInETH( + address _poolToken + ) public payable onlyRedeemable(_poolToken) returns (uint256) { + // create path & amounts uint256 fromAmount = msg.value; - address fromToken = eligibleTokenAddresses["WMATIC"]; - address[] memory path = generatePath(fromToken, _toToken); + // wrap the native token + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + address[] memory path = generatePath(fromToken, _poolToken); + uint256 len = path.length; // swap - uint256[] memory amounts = routerSushi().swapExactETHForTokens{ + uint256[] memory amounts = dexRouter().swapExactETHForTokens{ value: fromAmount }(0, path, address(this), block.timestamp); uint256 amountOut = amounts[len - 1]; // update balances - balances[msg.sender][_toToken] += amountOut; + balances[msg.sender][_poolToken] += amountOut; return amountOut; } @@ -587,7 +632,10 @@ contract OffsetHelper is OffsetHelperStorage { * @notice Allow users to deposit BCT / NCT. * @dev Needs to be approved */ - function deposit(address _erc20Addr, uint256 _amount) public onlyRedeemable(_erc20Addr) { + function deposit( + address _erc20Addr, + uint256 _amount + ) public onlyRedeemable(_erc20Addr) { IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount); balances[msg.sender][_erc20Addr] += _amount; } @@ -595,12 +643,15 @@ contract OffsetHelper is OffsetHelperStorage { /** * @notice Redeems the specified amount of NCT / BCT for TCO2. * @dev Needs to be approved on the client side - * @param _fromToken Could be the address of NCT or BCT + * @param _fromToken Could be the address of NCT * @param _amount Amount to redeem * @return tco2s An array of the TCO2 addresses that were redeemed * @return amounts An array of the amounts of each TCO2 that were redeemed */ - function autoRedeem(address _fromToken, uint256 _amount) + function autoRedeem( + address _fromToken, + uint256 _amount + ) public onlyRedeemable(_fromToken) returns (address[] memory tco2s, uint256[] memory amounts) @@ -610,7 +661,7 @@ contract OffsetHelper is OffsetHelperStorage { "Insufficient NCT/BCT balance" ); - // instantiate pool token (NCT or BCT) + // instantiate pool token (NCT) IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken); // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract @@ -632,9 +683,10 @@ contract OffsetHelper is OffsetHelperStorage { * @param _amounts The amounts to retire from each of the corresponding * TCO2 addresses */ - function autoRetire(address[] memory _tco2s, uint256[] memory _amounts) - public - { + function autoRetire( + address[] memory _tco2s, + uint256[] memory _amounts + ) public { uint256 tco2sLen = _tco2s.length; require(tco2sLen != 0, "Array empty"); @@ -665,15 +717,14 @@ contract OffsetHelper is OffsetHelperStorage { function calculateExactOutSwap( address _fromToken, - address _toToken, - uint256 _toAmount) - internal view - returns (address[] memory path, uint256[] memory amounts) - { - path = generatePath(_fromToken, _toToken); + address _poolToken, + uint256 _toAmount + ) internal view returns (address[] memory path, uint256[] memory amounts) { + // create path & calculate amounts + path = generatePath(_fromToken, _poolToken); uint256 len = path.length; - amounts = routerSushi().getAmountsIn(_toAmount, path); + amounts = dexRouter().getAmountsIn(_toAmount, path); // sanity check arrays require(len == amounts.length, "Arrays unequal"); @@ -682,42 +733,63 @@ contract OffsetHelper is OffsetHelperStorage { function calculateExactInSwap( address _fromToken, - uint256 _fromAmount, - address _toToken) - internal view - returns (address[] memory path, uint256[] memory amounts) - { - path = generatePath(_fromToken, _toToken); + address _poolToken, + uint256 _fromAmount + ) internal view returns (address[] memory path, uint256[] memory amounts) { + // create path & calculate amounts + path = generatePath(_fromToken, _poolToken); uint256 len = path.length; - amounts = routerSushi().getAmountsOut(_fromAmount, path); + amounts = dexRouter().getAmountsOut(_fromAmount, path); // sanity check arrays require(len == amounts.length, "Arrays unequal"); require(_fromAmount == amounts[0], "Input amount mismatch"); } - function generatePath(address _fromToken, address _toToken) - internal - view - returns (address[] memory) - { - if (_fromToken == eligibleTokenAddresses["USDC"]) { - address[] memory path = new address[](2); + /** + * @notice Show all pool token addresses that can be used to retired. + * @param _fromToken a list of token symbols that can be retired. + * @param _toToken a list of token symbols that can be retired. + */ + function generatePath( + address _fromToken, + address _toToken + ) internal view returns (address[] memory path) { + uint256 len = eligibleSwapPaths[_fromToken].length; + if (len == 1) { + path = new address[](2); path[0] = _fromToken; path[1] = _toToken; return path; - } else { - address[] memory path = new address[](3); + } + if (len == 2) { + path = new address[](3); path[0] = _fromToken; - path[1] = eligibleTokenAddresses["USDC"]; + path[1] = eligibleSwapPaths[_fromToken][1]; path[2] = _toToken; return path; } + if (len == 3) { + path = new address[](3); + path[0] = _fromToken; + path[1] = eligibleSwapPaths[_fromToken][1]; + path[2] = eligibleSwapPaths[_fromToken][2]; + path[3] = _toToken; + return path; + } else { + path = new address[](4); + path[0] = _fromToken; + path[1] = eligibleSwapPaths[_fromToken][1]; + path[2] = eligibleSwapPaths[_fromToken][2]; + path[3] = eligibleSwapPaths[_fromToken][3]; + path[4] = _toToken; + return path; + } } - function routerSushi() internal view returns (IUniswapV2Router02) { - return IUniswapV2Router02(sushiRouterAddress); + function dexRouter() internal view returns (IUniswapV2Router02) { + return IUniswapV2Router02(dexRouterAddress); } // ---------------------------------------- @@ -725,38 +797,72 @@ contract OffsetHelper is OffsetHelperStorage { // ---------------------------------------- /** - * @notice Change or add eligible tokens and their addresses. + * @notice Checks if ERC20 Token is eligible for Offsetting. + * @param _erc20Address The address of the ERC20 token that the user sends + * (e.g., cUSD, cUSD, USDC, WETH, WMATIC) + * @return _path Returns the path of the token to be exchanged + */ + + function isERC20AddressEligible( + address _erc20Address + ) public view returns (address[] memory _path) { + _path = eligibleSwapPaths[_erc20Address]; + } + + /** + * @notice Change or add eligible paths and their addresses. * @param _tokenSymbol The symbol of the token to add - * @param _address The address of the token to add + * @param _path The path of the path to add */ - function setEligibleTokenAddress( + function addPath( string memory _tokenSymbol, - address _address + address[] memory _path ) public virtual onlyOwner { - eligibleTokenAddresses[_tokenSymbol] = _address; + eligibleSwapPaths[_path[0]] = _path; + eligibleSwapPathsBySymbol[_tokenSymbol] = _path; + tokenSymbolsForPaths.push(_tokenSymbol); } /** * @notice Delete eligible tokens stored in the contract. - * @param _tokenSymbol The symbol of the token to remove + * @param _tokenSymbol The symbol of the path to remove */ - function deleteEligibleTokenAddress(string memory _tokenSymbol) - public - virtual - onlyOwner - { - delete eligibleTokenAddresses[_tokenSymbol]; + function removePath(string memory _tokenSymbol) public virtual onlyOwner { + delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]]; + delete eligibleSwapPathsBySymbol[_tokenSymbol]; } /** - * @notice Change the TCO2 contracts registry. - * @param _address The address of the Toucan contract registry to use + * @notice Cheks if Pool Token is eligible for Offsetting. + * @param _poolToken The addresses of the pool token to redeem + * @return _isEligible Returns if token can be redeemed */ - function setToucanContractRegistry(address _address) - public - virtual - onlyOwner - { - contractRegistryAddress = _address; + + function isPoolAddressEligible( + address _poolToken + ) public view returns (bool _isEligible) { + _isEligible = isRedeemable(_poolToken); + } + + /** + * @notice Change or add pool token addresses. + * @param _poolToken The address of the pool token to add + */ + function addPoolToken(address _poolToken) public virtual onlyOwner { + poolAddresses.push(_poolToken); + } + + /** + * @notice Delete eligible pool token addresses stored in the contract. + * @param _poolToken The address of the pool token to remove + */ + function removePoolToken(address _poolToken) public virtual onlyOwner { + for (uint256 i; i < poolAddresses.length; i++) { + if (poolAddresses[i] == _poolToken) { + poolAddresses[i] = poolAddresses[poolAddresses.length - 1]; + poolAddresses.pop(); + break; + } + } } } diff --git a/contracts/OffsetHelperStorage.sol b/contracts/OffsetHelperStorage.sol index a02a0db..3567120 100644 --- a/contracts/OffsetHelperStorage.sol +++ b/contracts/OffsetHelperStorage.sol @@ -8,11 +8,16 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract OffsetHelperStorage is OwnableUpgradeable { // token symbol => token address - mapping(string => address) public eligibleTokenAddresses; - address public contractRegistryAddress = - 0x263fA1c180889b3a3f46330F32a4a23287E99FC9; - address public sushiRouterAddress = + mapping(address => address[]) public eligibleSwapPaths; + mapping(string => address[]) public eligibleSwapPathsBySymbol; + + address public dexRouterAddress = 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; + + address[] public poolAddresses; + string[] public tokenSymbolsForPaths; + address[][] public paths; + // user => (token => amount) mapping(address => mapping(address => uint256)) public balances; } diff --git a/deploy/00_deploy_offsetHelper.ts b/deploy/00_deploy_offsetHelper.ts index 9fb63f7..06e813a 100644 --- a/deploy/00_deploy_offsetHelper.ts +++ b/deploy/00_deploy_offsetHelper.ts @@ -1,10 +1,15 @@ import { DeployFunction } from "hardhat-deploy/types"; import { HardhatRuntimeEnvironment } from "hardhat/types"; -import addresses, { mumbaiAddresses } from "../utils/addresses"; +import paths from "../utils/paths"; +import { poolAddresses } from "../utils/addresses"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const addressesToUse = - hre.network.name == "mumbai" ? mumbaiAddresses : addresses; + const pathsToUse = + paths[hre.network.name === "hardhat" ? "alfajores" : hre.network.name]; + const poolAddressesToUse = + poolAddresses[ + hre.network.name === "hardhat" ? "alfajores" : hre.network.name + ]; const { deployments, getNamedAccounts } = hre; const { deploy } = deployments; @@ -16,9 +21,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { await deploy("OffsetHelper", { from: deployer, - args: [Object.keys(addressesToUse), Object.values(addressesToUse)], + args: [ + Object.values(poolAddressesToUse), + Object.keys(pathsToUse), + Object.values(pathsToUse), + ], log: true, autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks }); + // await deploy("Swapper", { + // from: deployer, + // args: [ + // Object.values(pathsToUse), + // "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", // WMATIC + // ], + // log: true, + // autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks + // }); }; export default func; diff --git a/hardhat.config.ts b/hardhat.config.ts index ab012f9..834314a 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -40,20 +40,20 @@ const config: HardhatUserConfig = { }, networks: { polygon: { - url: - process.env.POLYGON_URL || "https://matic-mainnet.chainstacklabs.com", + url: process.env.RPC_ENDPOINT || "https://rpc.ankr.com/polygon", accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], }, mumbai: { - url: process.env.MUMBAI_URL || "https://matic-mumbai.chainstacklabs.com", + url: "https://rpc.ankr.com/polygon_mumbai", accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + chainId: 80001, }, hardhat: { forking: { url: - process.env.POLYGON_URL || + process.env.RPC_ENDPOINT || "https://polygon-mainnet.g.alchemy.com/v2/4rzRS2MH5LIunV6cejmLhQelv_Vd82rq", }, }, @@ -63,8 +63,8 @@ const config: HardhatUserConfig = { }, etherscan: { apiKey: { - polygon: process.env.POLYGONSCAN_API_KEY || "", - polygonMumbai: process.env.POLYGONSCAN_API_KEY || "", + polygon: process.env.BLOCK_EXPLORER_API_KEY || "", + polygonMumbai: process.env.BLOCK_EXPLORER_API_KEY || "", }, }, docgen: { diff --git a/tasks/verifyOffsetHelper.ts b/tasks/verifyOffsetHelper.ts index ad3fa97..51ea480 100644 --- a/tasks/verifyOffsetHelper.ts +++ b/tasks/verifyOffsetHelper.ts @@ -1,6 +1,7 @@ import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; -import addresses, { mumbaiAddresses } from "../utils/addresses"; +import paths from "../utils/paths"; +import { poolAddresses } from "../utils/addresses"; task("verify:offsetHelper", "Verifies the OffsetHelper") .addParam("address", "The OffsetHelper address") @@ -8,14 +9,15 @@ task("verify:offsetHelper", "Verifies the OffsetHelper") async (taskArgs: { address: any }, hre: HardhatRuntimeEnvironment) => { const { address } = taskArgs; - const addressesToUse = - hre.network.name == "mumbai" ? mumbaiAddresses : addresses; + const pathsToUse = paths[hre.network.name]; + const poolAddressesToUse = poolAddresses[hre.network.name]; await hre.run("verify:verify", { address: address, constructorArguments: [ - Object.keys(addressesToUse), - Object.values(addressesToUse), + Object.values(poolAddressesToUse), + Object.keys(pathsToUse), + Object.values(pathsToUse), ], }); console.log(`OffsetHelper verified on ${hre.network.name} to:`, address); From c26f6faca64a11cb7ba16c3a0869abcdf7859cf5 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:15:55 +0100 Subject: [PATCH 02/12] refactor: Add routerAddress Param to OffsetHelper and Swapper constructor --- contracts/OffsetHelper.sol | 4 +- contracts/OffsetHelperStorage.sol | 3 +- contracts/test/Swapper.sol | 90 +++++++++++++++++++------------ deploy/00_deploy_offsetHelper.ts | 8 ++- tasks/verifyOffsetHelper.ts | 2 + 5 files changed, 68 insertions(+), 39 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 0274438..3ffc5ce 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -102,11 +102,13 @@ contract OffsetHelper is OffsetHelperStorage { constructor( address[] memory _poolAddresses, string[] memory _tokenSymbolsForPaths, - address[][] memory _paths + address[][] memory _paths, + address _dexRouterAddress ) { poolAddresses = _poolAddresses; tokenSymbolsForPaths = _tokenSymbolsForPaths; paths = _paths; + dexRouterAddress = _dexRouterAddress; uint256 i = 0; uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length; diff --git a/contracts/OffsetHelperStorage.sol b/contracts/OffsetHelperStorage.sol index 3567120..d27741a 100644 --- a/contracts/OffsetHelperStorage.sol +++ b/contracts/OffsetHelperStorage.sol @@ -11,8 +11,7 @@ contract OffsetHelperStorage is OwnableUpgradeable { mapping(address => address[]) public eligibleSwapPaths; mapping(string => address[]) public eligibleSwapPathsBySymbol; - address public dexRouterAddress = - 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; + address public dexRouterAddress; address[] public poolAddresses; string[] public tokenSymbolsForPaths; diff --git a/contracts/test/Swapper.sol b/contracts/test/Swapper.sol index 2c88b92..7fcb5b0 100644 --- a/contracts/test/Swapper.sol +++ b/contracts/test/Swapper.sol @@ -7,44 +7,47 @@ import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; contract Swapper { using SafeERC20 for IERC20; - address public sushiRouterAddress = - 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; - mapping(string => address) public tokenAddresses; - - constructor(string[] memory _tokenSymbols, address[] memory _tokenAddresses) - { + mapping(address => address[]) public eligibleSwapPaths; + address public swapToken; + address public dexRouterAddress; + + constructor( + address[][] memory _paths, + address _swapToken, + address _dexRouterAddress + ) { + dexRouterAddress = _dexRouterAddress; + swapToken = _swapToken; uint256 i = 0; - while (i < _tokenSymbols.length) { - tokenAddresses[_tokenSymbols[i]] = _tokenAddresses[i]; + uint256 eligibleSwapPathsLen = _paths.length; + while (i < eligibleSwapPathsLen) { + eligibleSwapPaths[_paths[i][0]] = _paths[i]; i += 1; } } - function calculateNeededETHAmount(address _toToken, uint256 _amount) - public - view - returns (uint256) - { - IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress); + function calculateNeededETHAmount( + address _toToken, + uint256 _amount + ) public view returns (uint256) { + IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress); - address[] memory path = generatePath( - tokenAddresses["WMATIC"], - _toToken - ); + address[] memory path = generatePath(swapToken, _toToken); + uint256 len = path.length; - uint256[] memory amounts = routerSushi.getAmountsIn(_amount, path); + uint256[] memory amounts = dexRouter.getAmountsIn(_amount, path); + // sanity check arrays + require(len == amounts.length, "Arrays unequal"); + require(_amount == amounts[len - 1], "Output amount mismatch"); return amounts[0]; } function swap(address _toToken, uint256 _amount) public payable { - IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress); + IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress); - address[] memory path = generatePath( - tokenAddresses["WMATIC"], - _toToken - ); + address[] memory path = generatePath(swapToken, _toToken); - uint256[] memory amounts = routerSushi.swapETHForExactTokens{ + uint256[] memory amounts = dexRouter.swapETHForExactTokens{ value: msg.value }(_amount, path, address(this), block.timestamp); @@ -60,23 +63,40 @@ contract Swapper { } } - function generatePath(address _fromToken, address _toToken) - internal - view - returns (address[] memory) - { - if (_toToken == tokenAddresses["USDC"]) { - address[] memory path = new address[](2); + function generatePath( + address _fromToken, + address _toToken + ) internal view returns (address[] memory path) { + uint256 len = eligibleSwapPaths[_fromToken].length; + if (len == 1 || eligibleSwapPaths[_fromToken][1] == _toToken) { + path = new address[](2); path[0] = _fromToken; path[1] = _toToken; return path; - } else { - address[] memory path = new address[](3); + } + if (len == 2 || eligibleSwapPaths[_fromToken][2] == _toToken) { + path = new address[](3); path[0] = _fromToken; - path[1] = tokenAddresses["USDC"]; + path[1] = eligibleSwapPaths[_fromToken][1]; path[2] = _toToken; return path; } + if (len == 3 || eligibleSwapPaths[_fromToken][3] == _toToken) { + path = new address[](3); + path[0] = _fromToken; + path[1] = eligibleSwapPaths[_fromToken][1]; + path[2] = eligibleSwapPaths[_fromToken][2]; + path[3] = _toToken; + return path; + } else { + path = new address[](4); + path[0] = _fromToken; + path[1] = eligibleSwapPaths[_fromToken][1]; + path[2] = eligibleSwapPaths[_fromToken][2]; + path[3] = eligibleSwapPaths[_fromToken][3]; + path[4] = _toToken; + return path; + } } fallback() external payable {} diff --git a/deploy/00_deploy_offsetHelper.ts b/deploy/00_deploy_offsetHelper.ts index 06e813a..7b73bdd 100644 --- a/deploy/00_deploy_offsetHelper.ts +++ b/deploy/00_deploy_offsetHelper.ts @@ -1,7 +1,7 @@ import { DeployFunction } from "hardhat-deploy/types"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import paths from "../utils/paths"; -import { poolAddresses } from "../utils/addresses"; +import { poolAddresses, routerAddresses } from "../utils/addresses"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const pathsToUse = @@ -10,6 +10,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { poolAddresses[ hre.network.name === "hardhat" ? "alfajores" : hre.network.name ]; + const routerAddress = + routerAddresses[ + hre.network.name === "hardhat" ? "alfajores" : hre.network.name + ]; const { deployments, getNamedAccounts } = hre; const { deploy } = deployments; @@ -25,6 +29,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { Object.values(poolAddressesToUse), Object.keys(pathsToUse), Object.values(pathsToUse), + routerAddress, ], log: true, autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks @@ -34,6 +39,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // args: [ // Object.values(pathsToUse), // "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", // WMATIC + // routerAddress, // ], // log: true, // autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks diff --git a/tasks/verifyOffsetHelper.ts b/tasks/verifyOffsetHelper.ts index 51ea480..d7bc90a 100644 --- a/tasks/verifyOffsetHelper.ts +++ b/tasks/verifyOffsetHelper.ts @@ -11,6 +11,7 @@ task("verify:offsetHelper", "Verifies the OffsetHelper") const pathsToUse = paths[hre.network.name]; const poolAddressesToUse = poolAddresses[hre.network.name]; + const routerAddress = routerAddresses[hre.network.name]; await hre.run("verify:verify", { address: address, @@ -18,6 +19,7 @@ task("verify:offsetHelper", "Verifies the OffsetHelper") Object.values(poolAddressesToUse), Object.keys(pathsToUse), Object.values(pathsToUse), + routerAddress, ], }); console.log(`OffsetHelper verified on ${hre.network.name} to:`, address); From 13851f509a7e0456d37496fd0bbb54f01d8703b4 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:39:36 +0100 Subject: [PATCH 03/12] refactor: add proper return value functions without a defined return value, so it's properly reflected in the docs --- contracts/OffsetHelper.sol | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 3ffc5ce..336c9aa 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -351,7 +351,7 @@ contract OffsetHelper is OffsetHelperStorage { * @param _poolToken The address of the pool token to swap for, * e.g., NCT * @param _toAmount The desired amount of pool token to receive - * @return amountsIn The amount of the ERC20 token required in order to + * @return amountIn The amount of the ERC20 token required in order to * swap for the specified amount of the pool token */ function calculateNeededTokenAmount( @@ -363,14 +363,14 @@ contract OffsetHelper is OffsetHelperStorage { view onlySwappable(_fromToken) onlyRedeemable(_poolToken) - returns (uint256) + returns (uint256 amountIn) { (, uint256[] memory amounts) = calculateExactOutSwap( _fromToken, _poolToken, _toAmount ); - return amounts[0]; + amountIn = amounts[0]; } /** @@ -381,7 +381,7 @@ contract OffsetHelper is OffsetHelperStorage { * @param _poolToken The address of the pool token to swap for, * e.g., NCT * @param _fromAmount The amount of ERC20 token to swap - * @return The expected amount of Pool token that can be acquired + * @return amountOut The expected amount of Pool token that can be acquired */ function calculateExpectedPoolTokenForToken( address _fromToken, @@ -392,14 +392,14 @@ contract OffsetHelper is OffsetHelperStorage { view onlySwappable(_fromToken) onlyRedeemable(_poolToken) - returns (uint256) + returns (uint256 amountOut) { (, uint256[] memory amounts) = calculateExactInSwap( _fromToken, _poolToken, _fromAmount ); - return amounts[amounts.length - 1]; + amountOut = amounts[amounts.length - 1]; } /** @@ -458,7 +458,7 @@ contract OffsetHelper is OffsetHelperStorage { * @param _poolToken The address of the pool token to swap for, * @param _fromAmount The amount of ERC20 token to swap * e.g., NCT - * @return Resulting amount of Toucan pool token that got acquired for the + * @return amountOut Resulting amount of Toucan pool token that got acquired for the * swapped ERC20 tokens. */ function swapExactInToken( @@ -469,7 +469,7 @@ contract OffsetHelper is OffsetHelperStorage { public onlySwappable(_fromToken) onlyRedeemable(_poolToken) - returns (uint256) + returns (uint256 amountOut) { // calculate path & amounts @@ -495,12 +495,10 @@ contract OffsetHelper is OffsetHelperStorage { address(this), block.timestamp ); - uint256 amountOut = amounts[len - 1]; + amountOut = amounts[len - 1]; // update balances balances[msg.sender][_poolToken] += amountOut; - - return amountOut; } // apparently I need a fallback and a receive method to fix the situation where transfering dust native tokens @@ -513,20 +511,20 @@ contract OffsetHelper is OffsetHelperStorage { * @param _poolToken The address of the pool token to swap for, for * example, NCT * @param _toAmount The desired amount of pool token to receive - * @return amounts The amount of native tokens required in order to swap for + * @return amountIn The amount of native tokens required in order to swap for * the specified amount of the pool token */ function calculateNeededETHAmount( address _poolToken, uint256 _toAmount - ) public view onlyRedeemable(_poolToken) returns (uint256) { + ) public view onlyRedeemable(_poolToken) returns (uint256 amountIn) { address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; (, uint256[] memory amounts) = calculateExactOutSwap( fromToken, _poolToken, _toAmount ); - return amounts[0]; + amountIn = amounts[0]; } /** @@ -536,19 +534,19 @@ contract OffsetHelper is OffsetHelperStorage { * @param _fromTokenAmount The amount of native tokens to swap * @param _poolToken The address of the pool token to swap for, * e.g., NCT - * @return The expected amount of Pool token that can be acquired + * @return amountOut The expected amount of Pool token that can be acquired */ function calculateExpectedPoolTokenForETH( address _poolToken, uint256 _fromTokenAmount - ) public view onlyRedeemable(_poolToken) returns (uint256) { + ) public view onlyRedeemable(_poolToken) returns (uint256 amountOut) { address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; (, uint256[] memory amounts) = calculateExactInSwap( fromToken, _poolToken, _fromTokenAmount ); - return amounts[amounts.length - 1]; + amountOut = amounts[amounts.length - 1]; } /** @@ -591,12 +589,12 @@ contract OffsetHelper is OffsetHelperStorage { * provided native tokens will be swapped. * @param _poolToken The address of the pool token to swap for, * e.g., NCT - * @return Resulting amount of Toucan pool token that got acquired for the + * @return amountOut Resulting amount of Toucan pool token that got acquired for the * swapped native tokens . */ function swapExactInETH( address _poolToken - ) public payable onlyRedeemable(_poolToken) returns (uint256) { + ) public payable onlyRedeemable(_poolToken) returns (uint256 amountOut) { // create path & amounts uint256 fromAmount = msg.value; // wrap the native token @@ -609,12 +607,10 @@ contract OffsetHelper is OffsetHelperStorage { uint256[] memory amounts = dexRouter().swapExactETHForTokens{ value: fromAmount }(0, path, address(this), block.timestamp); - uint256 amountOut = amounts[len - 1]; + amountOut = amounts[len - 1]; // update balances balances[msg.sender][_poolToken] += amountOut; - - return amountOut; } /** From 2227dc8be7b7e8d55be84f23221b545590c66369 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:24:45 +0100 Subject: [PATCH 04/12] fix: Add initialisation of the owner --- contracts/OffsetHelper.sol | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 336c9aa..6a6dbbf 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -119,6 +119,14 @@ contract OffsetHelper is OffsetHelperStorage { } } + // ---------------------------------------- + // Upgradable related functions + // ---------------------------------------- + + function initialize() external virtual initializer { + __Ownable_init_unchained(); + } + /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 * tokens available from the specified Toucan token pool by sending ERC20 From 76f571f3eca31a8fe3e7175e211ffd4c5eb6511a Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:10:07 +0100 Subject: [PATCH 05/12] feature: Add all paths, addresses, config to deploy on Celo --- deployments/alfajores/.chainId | 1 + deployments/celo/.chainId | 1 + hardhat.config.ts | 32 +++++++++++++ utils/addresses.ts | 81 ++++++++++++++++++++++++++------ utils/paths.ts | 84 ++++++++++++++++++++++++++++++++++ utils/tokens.ts | 2 +- 6 files changed, 185 insertions(+), 16 deletions(-) create mode 100644 deployments/alfajores/.chainId create mode 100644 deployments/celo/.chainId create mode 100644 utils/paths.ts diff --git a/deployments/alfajores/.chainId b/deployments/alfajores/.chainId new file mode 100644 index 0000000..38448fe --- /dev/null +++ b/deployments/alfajores/.chainId @@ -0,0 +1 @@ +44787 \ 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/hardhat.config.ts b/hardhat.config.ts index 834314a..7e90ef4 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -39,6 +39,18 @@ const config: HardhatUserConfig = { }, }, networks: { + alfajores: { + url: "https://alfajores-forno.celo-testnet.org", + accounts: + process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + chainId: 44787, + }, + celo: { + url: process.env.RPC_ENDPOINT || "https://rpc.ankr.com/celo", + accounts: + process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + chainId: 42220, + }, polygon: { url: process.env.RPC_ENDPOINT || "https://rpc.ankr.com/polygon", accounts: @@ -65,7 +77,27 @@ const config: HardhatUserConfig = { apiKey: { polygon: process.env.BLOCK_EXPLORER_API_KEY || "", polygonMumbai: process.env.BLOCK_EXPLORER_API_KEY || "", + celo: process.env.BLOCK_EXPLORER_API_KEY || "", + alfajores: process.env.BLOCK_EXPLORER_API_KEY || "", }, + customChains: [ + { + network: "celo", + chainId: 42220, + urls: { + apiURL: `https://api.celoscan.io/api`, + browserURL: "https://celoscan.io/", + }, + }, + { + network: "alfajores", + chainId: 44787, + urls: { + apiURL: `https://api.celoscan.io/api`, + browserURL: "https://celoscan.io/", + }, + }, + ], }, docgen: { pages: (item: any, file: any) => diff --git a/utils/addresses.ts b/utils/addresses.ts index ee692f3..85fc4da 100644 --- a/utils/addresses.ts +++ b/utils/addresses.ts @@ -1,25 +1,76 @@ -interface IfcAddresses { +interface IfcOneNetworkAddresses { BCT: string; NCT: string; - USDC: string; - WETH: string; - WMATIC: string; + mcUSD?: string; + cUSD?: string; + CELO?: string; + WETH?: string; + USDC?: string; + WMATIC?: string; +} +interface IfcAddresses { + celo: IfcOneNetworkAddresses; + alfajores: IfcOneNetworkAddresses; + polygon: IfcOneNetworkAddresses; + mumbai: IfcOneNetworkAddresses; } const addresses: IfcAddresses = { - BCT: "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", - NCT: "0xD838290e877E0188a4A44700463419ED96c16107", - USDC: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", - WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", - WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + celo: { + BCT: "0x0CcB0071e8B8B716A2a5998aB4d97b83790873Fe", + NCT: "0x02De4766C272abc10Bc88c220D214A26960a7e92", + mcUSD: "0xE273Ad7ee11dCfAA87383aD5977EE1504aC07568", + cUSD: "0x765DE816845861e75A25fCA122bb6898B8B1282a", + CELO: "0x471EcE3750Da237f93B8E339c536989b8978a438", + WETH: "0x122013fd7dF1C6F636a5bb8f03108E876548b455", + USDC: "0xef4229c8c3250C675F21BCefa42f58EfbfF6002a", + }, + alfajores: { + BCT: "0x4c5f90C50Ca9F849bb75D93a393A4e1B6E68Accb", + NCT: "0xfb60a08855389F3c0A66b29aB9eFa911ed5cbCB5", + cUSD: "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", + CELO: "0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9", + }, + polygon: { + BCT: "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", + NCT: "0xD838290e877E0188a4A44700463419ED96c16107", + USDC: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + }, + mumbai: { + BCT: "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", + NCT: "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E", + USDC: "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", + WETH: "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", + WMATIC: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", + }, +}; + +export const poolAddresses: IfcNetworkPoolAddresses = { + celo: { + BCT: "0x0CcB0071e8B8B716A2a5998aB4d97b83790873Fe", + NCT: "0x02De4766C272abc10Bc88c220D214A26960a7e92", + }, + alfajores: { + BCT: "0x4c5f90C50Ca9F849bb75D93a393A4e1B6E68Accb", + NCT: "0xfb60a08855389F3c0A66b29aB9eFa911ed5cbCB5", + }, + polygon: { + BCT: "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", + NCT: "0xD838290e877E0188a4A44700463419ED96c16107", + }, + mumbai: { + BCT: "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", + NCT: "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E", + }, }; -export const mumbaiAddresses: IfcAddresses = { - BCT: "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", - NCT: "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E", - USDC: "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", - WETH: "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", - WMATIC: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", +export const routerAddresses = { + celo: "0x7D28570135A2B1930F331c507F65039D4937f66c", // ubeswap + alfajores: "0x7D28570135A2B1930F331c507F65039D4937f66c", // ubeswap + polygon: "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", // sushiswap + mumbai: "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", // sushiswap }; export default addresses; diff --git a/utils/paths.ts b/utils/paths.ts new file mode 100644 index 0000000..39b743f --- /dev/null +++ b/utils/paths.ts @@ -0,0 +1,84 @@ +interface IfcPoolAddresses { + BCT: string; + NCT: string; +} +interface IfcTokenAddresses { + mcUSD?: string[]; + cUSD?: string[]; + CELO?: string[]; + WETH?: string[]; + USDC?: string[]; + WMATIC?: string[]; +} +interface IfcNetworkTokenAddresses { + celo: IfcTokenAddresses; + alfajores: IfcTokenAddresses; + polygon: IfcTokenAddresses; + mumbai: IfcTokenAddresses; +} +interface IfcNetworkPoolAddresses { + celo: IfcPoolAddresses; + alfajores: IfcPoolAddresses; + polygon: IfcPoolAddresses; + mumbai: IfcPoolAddresses; +} + +const paths: IfcNetworkTokenAddresses = { + celo: { + mcUSD: ["0x918146359264c492bd6934071c6bd31c854edbc3"], + cUSD: [ + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3", + ], + CELO: [ + "0x471EcE3750Da237f93B8E339c536989b8978a438", + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3", + ], + WETH: [ + "0x122013fd7dF1C6F636a5bb8f03108E876548b455", + "0x918146359264c492bd6934071c6bd31c854edbc3", + ], + USDC: [ + "0xef4229c8c3250C675F21BCefa42f58EfbfF6002a", + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3", + ], + }, + alfajores: { + mcUSD: ["0x71DB38719f9113A36e14F409bAD4F07B58b4730b"], + cUSD: [ + "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", + "0x71DB38719f9113A36e14F409bAD4F07B58b4730b", + ], + CELO: [ + "0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9", + "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", + "0x71DB38719f9113A36e14F409bAD4F07B58b4730b", + ], + }, + polygon: { + USDC: ["0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"], + WETH: [ + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + ], + WMATIC: [ + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + ], + }, + mumbai: { + USDC: ["0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747"], + WETH: [ + "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", + ], + WMATIC: [ + "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", + ], + }, +}; + +export default paths; diff --git a/utils/tokens.ts b/utils/tokens.ts index e5c4d7f..96ba326 100644 --- a/utils/tokens.ts +++ b/utils/tokens.ts @@ -1 +1 @@ -export const tokens = ["BCT", "NCT", "USDC", "WETH", "WMATIC"]; +export const tokens = ["BCT", "NCT", "USDC", "WETH", "WMATIC", "cUSD", "CELO"]; From 47ec131f40013cc37677feb8a65403044a9c0cf4 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:23:29 +0100 Subject: [PATCH 06/12] feature: Add modifier to check for chain, to throw error when calling ETH functions on Celo --- contracts/OffsetHelper.sol | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 6a6dbbf..8511a8c 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -56,6 +56,8 @@ import "./interfaces/IToucanContractRegistry.sol"; */ contract OffsetHelper is OffsetHelperStorage { using SafeERC20 for IERC20; + // Chain ID of Celo mainnet + uint256 private constant CELO_MAINNET_CHAINID = 42220; /** * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan @@ -86,6 +88,15 @@ contract OffsetHelper is OffsetHelperStorage { _; } + modifier nativeTokenChain() { + require( + block.chainid != CELO_MAINNET_CHAINID, + "The function is not available on this network." + ); + + _; + } + /** * @notice Contract constructor. Should specify arrays of ERC20 symbols and * addresses that can used by the contract. @@ -242,6 +253,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable + nativeTokenChain returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -277,6 +289,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable + nativeTokenChain returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -480,7 +493,6 @@ contract OffsetHelper is OffsetHelperStorage { returns (uint256 amountOut) { // calculate path & amounts - address[] memory path = generatePath(_fromToken, _poolToken); uint256 len = path.length; @@ -567,7 +579,7 @@ contract OffsetHelper is OffsetHelperStorage { function swapExactOutETH( address _poolToken, uint256 _toAmount - ) public payable onlyRedeemable(_poolToken) { + ) public payable nativeTokenChain onlyRedeemable(_poolToken) { // create path & amounts // wrap the native token address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; From 22e2f24cacad9f9c427f96e4e8970845715d505f Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:39:29 +0100 Subject: [PATCH 07/12] test: Adapt tests to new OffsetHelper, remove unused code from impersonateAccount file --- test/OffsetHelper.test.ts | 440 +++++++++++++++++++++++------------- utils/impersonateAccount.ts | 2 - 2 files changed, 282 insertions(+), 160 deletions(-) diff --git a/test/OffsetHelper.test.ts b/test/OffsetHelper.test.ts index 3afac91..a103153 100644 --- a/test/OffsetHelper.test.ts +++ b/test/OffsetHelper.test.ts @@ -1,25 +1,21 @@ // SPDX-License-Identifier: GPL-3.0 -import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs"; import { expect } from "chai"; import { ethers } from "hardhat"; import { formatEther, parseEther, parseUnits } from "ethers/lib/utils"; - +import addresses, { poolAddresses, routerAddresses } from "../utils/addresses"; +import paths from "../utils/paths"; import { IERC20, IERC20__factory, - IWETH, IWETH__factory, IToucanPoolToken, IToucanPoolToken__factory, - OffsetHelper, OffsetHelper__factory, - Swapper, Swapper__factory, } from "../typechain"; -import addresses from "../utils/addresses"; import { BigNumber } from "ethers"; import { sum as sumBN } from "../utils/bignumber"; @@ -27,6 +23,13 @@ type token = { name: string; token: () => IToucanPoolToken; }; +type networkType = "celo" | "polygon"; +const network: networkType = "polygon"; +const swapToken = "WMATIC"; +const networkAddresses = addresses[network]; +const networkPaths = paths[network]; +const networkPoolAddress = poolAddresses[network]; +const routerAddress = routerAddresses[network]; const ONE_ETHER = parseEther("1.0"); @@ -38,22 +41,37 @@ describe("OffsetHelper", function () { const TOKEN_POOLS = ["nct", "bct"]; async function deployOffsetHelperFixture() { - const [addr1, addr2, ...addrs] = await ethers.getSigners(); + const [owner, addr2, ...addrs] = await ethers.getSigners(); const offsetHelperFactory = (await ethers.getContractFactory( "OffsetHelper", - addr2 + owner )) as OffsetHelper__factory; - const offsetHelper = await offsetHelperFactory.deploy( - Object.keys(addresses), - Object.values(addresses) + + const offsetHelper = await offsetHelperFactory?.deploy( + Object.values(networkPoolAddress), + Object.keys(networkPaths), + Object.values(networkPaths), + routerAddress ); - const bct = IToucanPoolToken__factory.connect(addresses.BCT, addr2); - const nct = IToucanPoolToken__factory.connect(addresses.NCT, addr2); - const usdc = IERC20__factory.connect(addresses.USDC, addr2); - const weth = IERC20__factory.connect(addresses.WETH, addr2); - const wmatic = IWETH__factory.connect(addresses.WMATIC, addr2); + await offsetHelper.initialize(); + + const bct = IToucanPoolToken__factory.connect( + networkPoolAddress.BCT, + owner + ); + const nct = IToucanPoolToken__factory.connect( + networkPoolAddress.NCT, + owner + ); + + const usdc = IERC20__factory.connect(networkAddresses.USDC, owner); + const weth = IERC20__factory.connect(networkAddresses.WETH, owner); + const testToken = IWETH__factory.connect( + networkAddresses[swapToken], + owner + ); const tokens: Record = { nct: { @@ -68,56 +86,52 @@ describe("OffsetHelper", function () { const swapperFactory = (await ethers.getContractFactory( "Swapper", - addr2 + owner )) as Swapper__factory; + const swapper = await swapperFactory.deploy( - ["BCT", "NCT", "USDC", "WETH", "WMATIC"], - [ - addresses.BCT, - addresses.NCT, - addresses.USDC, - addresses.WETH, - addresses.WMATIC, - ] + Object.values(networkPaths), + networkAddresses[swapToken], + routerAddress ); await Promise.all( addrs.map(async (addr) => { await addr.sendTransaction({ - to: addr2.address, + to: owner.address, value: (await addr.getBalance()).sub(ONE_ETHER), }); }) ); - await IWETH__factory.connect(addresses.WMATIC, addr2).deposit({ + // Get cUSD, WMATIC, WETH, USDC fo testing + await IWETH__factory.connect(networkAddresses[swapToken], owner).deposit({ value: parseEther("1000"), }); - - await swapper.swap(addresses.WETH, parseEther("20.0"), { + await swapper.swap(networkAddresses.WETH, parseEther("20.0"), { value: await swapper.calculateNeededETHAmount( - addresses.WETH, + networkAddresses.WETH, parseEther("20.0") ), }); - await swapper.swap(addresses.USDC, parseUSDC("1000"), { + await swapper.swap(networkAddresses.USDC, parseUSDC("10.0"), { value: await swapper.calculateNeededETHAmount( - addresses.USDC, - parseUSDC("1000") + networkAddresses.USDC, + parseUSDC("10.0") ), }); - await swapper.swap(addresses.BCT, parseEther("50.0"), { + await swapper.swap(networkPoolAddress.BCT, parseEther("50.0"), { value: await swapper.calculateNeededETHAmount( - addresses.BCT, + networkPoolAddress.BCT, parseEther("50.0") ), }); - await swapper.swap(addresses.NCT, parseEther("50.0"), { + await swapper.swap(networkPoolAddress.NCT, parseEther("50.0"), { value: await swapper.calculateNeededETHAmount( - addresses.NCT, + networkPoolAddress.NCT, parseEther("50.0") ), }); @@ -125,29 +139,74 @@ describe("OffsetHelper", function () { return { offsetHelper, weth, - wmatic, + testToken, usdc, - addr1, + owner, addr2, addrs, tokens, }; } + describe("#isERC20AddressEligible()", function () { + it("should be true when weth is being used to pay for retirement", async function () { + const { offsetHelper, weth } = await loadFixture( + deployOffsetHelperFixture + ); + + const path = await offsetHelper.isERC20AddressEligible(weth.address); + expect(path.length).to.equal(networkPaths.WETH?.length); + }); + it("should be false when inputing a non valid ERC20 token you want to use to pay for retirement", async function () { + const { offsetHelper } = await loadFixture(deployOffsetHelperFixture); + + const path = await offsetHelper.isERC20AddressEligible( + "0x8A4d7458dDe3023A3B24225D62087701A88b09DD" + ); + expect(path.length).to.equal(0); + }); + }); + + describe("#isPoolAddressEligible()", function () { + it(`should be true when inputing BCT`, async function () { + const { offsetHelper } = await loadFixture(deployOffsetHelperFixture); + + expect( + await offsetHelper.isPoolAddressEligible(networkPoolAddress.BCT) + ).to.equal(true); + }); + it(`should be true when inputing NCT`, async function () { + const { offsetHelper } = await loadFixture(deployOffsetHelperFixture); + + expect( + await offsetHelper.isPoolAddressEligible(networkPoolAddress.NCT) + ).to.equal(true); + }); + it(`should be false when inputing a non-valid pool address`, async function () { + const { offsetHelper } = await loadFixture(deployOffsetHelperFixture); + + expect( + await offsetHelper.isPoolAddressEligible( + "0x8A4d7458dDe3023A3B24225D62087701A88b09DD" + ) + ).to.equal(false); + }); + }); + describe("#autoOffsetExactInToken()", function () { async function retireFixedInToken( fromToken: IERC20, fromAmount: BigNumber, poolToken: IToucanPoolToken ) { - const { offsetHelper, addr2 } = await loadFixture( + const { offsetHelper, owner } = await loadFixture( deployOffsetHelperFixture ); const expOffset = await offsetHelper.calculateExpectedPoolTokenForToken( fromToken.address, - fromAmount, - poolToken.address + poolToken.address, + fromAmount ); // sanity check expect(expOffset).to.be.greaterThan(0); @@ -158,22 +217,22 @@ describe("OffsetHelper", function () { await expect( offsetHelper.autoOffsetExactInToken( fromToken.address, - fromAmount, - poolToken.address + poolToken.address, + fromAmount ) ) .to.emit(offsetHelper, "Redeemed") .withArgs( - addr2.address, + owner.address, poolToken.address, anyValue, (amounts: BigNumber[]) => { - return expOffset == sumBN(amounts); + return expOffset === sumBN(amounts); } ) .and.to.changeTokenBalance( fromToken, - addr2.address, + owner.address, fromAmount.mul(-1) ); @@ -185,19 +244,26 @@ describe("OffsetHelper", function () { it(`should retire 1 WETH for ${name.toUpperCase()} redemption`, async function () { const { weth, tokens } = await loadFixture(deployOffsetHelperFixture); const poolToken = tokens[name]; + await retireFixedInToken(weth, ONE_ETHER, poolToken.token()); }); - it(`should retire 100 USDC for ${name.toUpperCase()} redemption`, async function () { + it(`should retire 10 USDC for ${name.toUpperCase()} redemption`, async function () { const { usdc, tokens } = await loadFixture(deployOffsetHelperFixture); const poolToken = tokens[name]; - await retireFixedInToken(usdc, parseUSDC("100"), poolToken.token()); + await retireFixedInToken(usdc, parseUSDC("10"), poolToken.token()); }); it(`should retire 20 WMATIC for ${name.toUpperCase()} redemption`, async function () { - const { wmatic, tokens } = await loadFixture(deployOffsetHelperFixture); + const { testToken, tokens } = await loadFixture( + deployOffsetHelperFixture + ); const poolToken = tokens[name]; - await retireFixedInToken(wmatic, parseEther("20"), poolToken.token()); + await retireFixedInToken( + testToken, + parseEther("20"), + poolToken.token() + ); }); } }); @@ -207,13 +273,13 @@ describe("OffsetHelper", function () { fromAmount: BigNumber, poolToken: IToucanPoolToken ) { - const { offsetHelper, addr2 } = await loadFixture( + const { offsetHelper, owner } = await loadFixture( deployOffsetHelperFixture ); const expOffset = await offsetHelper.calculateExpectedPoolTokenForETH( - fromAmount, - poolToken.address + poolToken.address, + fromAmount ); // sanity check, should easily be > 1 tonne for all provided inputs expect(expOffset).to.be.greaterThan(0); @@ -226,21 +292,21 @@ describe("OffsetHelper", function () { ) .to.emit(offsetHelper, "Redeemed") .withArgs( - addr2.address, + owner.address, poolToken.address, anyValue, (amounts: BigNumber[]) => { - return expOffset == sumBN(amounts); + return expOffset === sumBN(amounts); } ) - .and.to.changeEtherBalance(addr2.address, fromAmount.mul(-1)); + .and.to.changeEtherBalance(owner.address, fromAmount.mul(-1)); const supplyAfter = await poolToken.totalSupply(); expect(supplyBefore.sub(supplyAfter)).to.equal(expOffset); } for (const name of TOKEN_POOLS) { - it(`should retire 20 MATIC for ${name.toUpperCase()} redemption`, async function () { + it(`should retire 20 native Token, e.g., MATIC for ${name.toUpperCase()} redemption`, async function () { const { tokens } = await loadFixture(deployOffsetHelperFixture); const poolToken = tokens[name]; await retireFixedInETH(parseEther("20"), poolToken.token()); @@ -250,30 +316,30 @@ describe("OffsetHelper", function () { describe("#autoOffsetExactOut{ETH,Token}()", function () { for (const name of TOKEN_POOLS) { - it(`should retire 1.0 TCO2 using a MATIC swap and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + it(`should retire 1.0 TCO2 using a Token swap and ${name.toUpperCase()} redemption`, async function () { + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop const poolToken = tokens[name]; // first we set the initial chain state - const maticBalanceBefore = await addr2.getBalance(); + const testTokenBalanceBefore = await owner.getBalance(); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); - // then we calculate the cost in MATIC of retiring 1.0 TCO2 - const maticCost = await offsetHelper.calculateNeededETHAmount( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + // then we calculate the cost in Token of retiring 1.0 TCO2 + const testTokenCost = await offsetHelper.calculateNeededETHAmount( + networkPoolAddress[poolToken.name], ONE_ETHER ); - // then we use the autoOffset function to retire 1.0 TCO2 from MATIC using NCT + // then we use the autoOffset function to retire 1.0 TCO2 from native Token, e.g., MATIC using NCT const tx = await ( await offsetHelper.autoOffsetExactOutETH( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER, { - value: maticCost, + value: testTokenCost, } ) ).wait(); @@ -282,14 +348,16 @@ describe("OffsetHelper", function () { const txFees = tx.gasUsed.mul(tx.effectiveGasPrice); // and we set the chain state after the transaction - const maticBalanceAfter = await addr2.getBalance(); + const testTokenBalanceAfter = await owner.getBalance(); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // lastly we compare chain states expect( - formatEther(maticBalanceBefore.sub(maticBalanceAfter)), - `User should have spent ${formatEther(maticCost)}} MATIC` - ).to.equal(formatEther(maticCost.add(txFees))); + formatEther(testTokenBalanceBefore.sub(testTokenBalanceAfter)), + `User should have spent ${formatEther( + testTokenCost + )}} native Token, e.g., MATIC` + ).to.equal(formatEther(testTokenCost.add(txFees))); expect( formatEther(poolTokenSupplyBefore.sub(poolTokenSupplyAfter)), `Total supply of ${name.toUpperCase()} should have decreased by 1` @@ -297,7 +365,7 @@ describe("OffsetHelper", function () { }); it(`should retire 1.0 TCO2 using a ${name.toUpperCase()} deposit and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop @@ -306,7 +374,7 @@ describe("OffsetHelper", function () { // first we set the initial chain state const poolTokenBalanceBefore = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); // then we use the autoOffset function to retire 1.0 TCO2 from NCT/BCT @@ -314,14 +382,15 @@ describe("OffsetHelper", function () { await poolToken.token().approve(offsetHelper.address, ONE_ETHER) ).wait(); await offsetHelper.autoOffsetPoolToken( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], + ONE_ETHER ); // then we set the chain state after the transaction const poolTokenBalanceAfter = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // and we compare chain states @@ -336,7 +405,7 @@ describe("OffsetHelper", function () { }); it(`should retire 1.0 TCO2 using a ${name.toUpperCase()} deposit and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop @@ -345,7 +414,7 @@ describe("OffsetHelper", function () { // first we set the initial chain state const poolTokenBalanceBefore = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); // then we use the autoOffset function to retire 1.0 TCO2 from NCT/BCT @@ -353,14 +422,15 @@ describe("OffsetHelper", function () { await poolToken.token().approve(offsetHelper.address, ONE_ETHER) ).wait(); await offsetHelper.autoOffsetPoolToken( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], + ONE_ETHER ); // then we set the chain state after the transaction const poolTokenBalanceAfter = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // and we compare chain states @@ -375,33 +445,33 @@ describe("OffsetHelper", function () { }); it(`should retire 1.0 TCO2 using a USDC swap and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, usdc, tokens } = await loadFixture( + const { offsetHelper, owner, usdc, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop const poolToken = tokens[name]; // first we set the initial chain state - const usdcBalanceBefore = await usdc.balanceOf(addr2.address); + const usdcBalanceBefore = await usdc.balanceOf(owner.address); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); // then we calculate the cost in USDC of retiring 1.0 TCO2 const usdcCost = await offsetHelper.calculateNeededTokenAmount( - addresses.USDC, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.USDC, + networkPoolAddress[poolToken.name], ONE_ETHER ); // then we use the autoOffset function to retire 1.0 TCO2 from USDC using NCT/BCT await (await usdc.approve(offsetHelper.address, usdcCost)).wait(); await offsetHelper.autoOffsetExactOutToken( - addresses.USDC, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.USDC, + networkPoolAddress[poolToken.name], ONE_ETHER ); // then we set the chain state after the transaction - const usdcBalanceAfter = await usdc.balanceOf(addr2.address); + const usdcBalanceAfter = await usdc.balanceOf(owner.address); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // and we compare chain states @@ -416,40 +486,44 @@ describe("OffsetHelper", function () { }); it(`should retire 1.0 TCO2 using a WMATIC swap and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, wmatic, tokens } = await loadFixture( + const { offsetHelper, owner, testToken, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop const poolToken = tokens[name]; // then we set the initial chain state - const wmaticBalanceBefore = await wmatic.balanceOf(addr2.address); + const testTokenBalanceBefore = await testToken.balanceOf(owner.address); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); // and we calculate the cost in WMATIC of retiring 1.0 TCO2 - const wmaticCost = await offsetHelper.calculateNeededTokenAmount( - addresses.WMATIC, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + const testTokenCost = await offsetHelper.calculateNeededTokenAmount( + networkAddresses[swapToken], + networkPoolAddress[poolToken.name], + ONE_ETHER ); // we use the autoOffset function to retire 1.0 TCO2 from WMATIC using NCT - await (await wmatic.approve(offsetHelper.address, wmaticCost)).wait(); + await ( + await testToken.approve(offsetHelper.address, testTokenCost) + ).wait(); await offsetHelper.autoOffsetExactOutToken( - addresses.WMATIC, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses[swapToken], + networkPoolAddress[poolToken.name], + ONE_ETHER ); // then we set the chain state after the transaction - const wmaticBalanceAfter = await wmatic.balanceOf(addr2.address); + const testTokenBalanceAfter = await testToken.balanceOf(owner.address); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // and we compare chain states expect( - formatEther(wmaticBalanceBefore.sub(wmaticBalanceAfter)), - `User should have spent ${formatEther(wmaticCost)} WMATIC` - ).to.equal(formatEther(wmaticCost)); + formatEther(testTokenBalanceBefore.sub(testTokenBalanceAfter)), + `User should have spent ${formatEther(testTokenCost)} WMATIC` + ).to.equal(formatEther(testTokenCost)); expect( formatEther(poolTokenSupplyBefore.sub(poolTokenSupplyAfter)), `Total supply of ${poolToken.name} should have decreased by 1` @@ -457,33 +531,35 @@ describe("OffsetHelper", function () { }); it(`should retire 1.0 TCO2 using a WETH swap and ${name.toUpperCase()} redemption`, async function () { - const { offsetHelper, addr2, weth, tokens } = await loadFixture( + const { offsetHelper, owner, weth, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop const poolToken = tokens[name]; // first we set the initial chain state - const wethBalanceBefore = await weth.balanceOf(addr2.address); + const wethBalanceBefore = await weth.balanceOf(owner.address); const poolTokenSupplyBefore = await poolToken.token().totalSupply(); // then we calculate the cost in WETH of retiring 1.0 TCO2 const wethCost = await offsetHelper.calculateNeededTokenAmount( - addresses.WETH, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.WETH, + networkPoolAddress[poolToken.name], + ONE_ETHER ); // then we use the autoOffset function to retire 1.0 TCO2 from WETH using pool token await (await weth.approve(offsetHelper.address, wethCost)).wait(); await offsetHelper.autoOffsetExactOutToken( - addresses.WETH, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.WETH, + networkPoolAddress[poolToken.name], + ONE_ETHER ); // then we set the chain state after the transaction - const wethBalanceAfter = await weth.balanceOf(addr2.address); + const wethBalanceAfter = await weth.balanceOf(owner.address); const poolTokenSupplyAfter = await poolToken.token().totalSupply(); // and we compare chain states @@ -508,15 +584,12 @@ describe("OffsetHelper", function () { const poolToken = tokens[name]; await expect( - offsetHelper.autoRedeem( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, - ONE_ETHER - ) + offsetHelper.autoRedeem(networkPoolAddress[poolToken.name], ONE_ETHER) ).to.be.revertedWith("Insufficient NCT/BCT balance"); }); it(`should redeem ${name.toUpperCase()} from deposit`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop @@ -531,7 +604,7 @@ describe("OffsetHelper", function () { states.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -544,7 +617,7 @@ describe("OffsetHelper", function () { ).wait(); await ( await offsetHelper.deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); @@ -553,7 +626,7 @@ describe("OffsetHelper", function () { states.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -582,7 +655,7 @@ describe("OffsetHelper", function () { // we redeem 1.0 pool token from the OH contract for TCO2s await offsetHelper.autoRedeem( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ); @@ -590,7 +663,7 @@ describe("OffsetHelper", function () { states.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -631,7 +704,7 @@ describe("OffsetHelper", function () { for (const name of TOKEN_POOLS) { it(`should retire using an ${name.toUpperCase()} deposit`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); // extracting the the pool token for this loop @@ -646,7 +719,7 @@ describe("OffsetHelper", function () { state.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -659,7 +732,7 @@ describe("OffsetHelper", function () { ).wait(); await ( await offsetHelper.deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); @@ -668,7 +741,7 @@ describe("OffsetHelper", function () { state.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -696,7 +769,7 @@ describe("OffsetHelper", function () { // we redeem pool token for TCO2 within OH const redeemReceipt = await ( await offsetHelper.autoRedeem( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); @@ -705,7 +778,7 @@ describe("OffsetHelper", function () { state.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -742,7 +815,7 @@ describe("OffsetHelper", function () { state.push({ userPoolTokenBalance: await poolToken .token() - .balanceOf(addr2.address), + .balanceOf(owner.address), contractPoolTokenBalance: await poolToken .token() .balanceOf(offsetHelper.address), @@ -783,22 +856,19 @@ describe("OffsetHelper", function () { await expect( offsetHelper .connect(addrs[0]) - .deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, - ONE_ETHER - ) + .deposit(networkPoolAddress[poolToken.name], ONE_ETHER) ).to.be.revertedWith("ERC20: transfer amount exceeds balance"); }); it(`should deposit and withdraw 1.0 ${name.toUpperCase()}`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); const poolToken = tokens[name]; const preDepositPoolTokenBalance = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); await ( await poolToken.token().approve(offsetHelper.address, ONE_ETHER) @@ -806,21 +876,21 @@ describe("OffsetHelper", function () { await ( await offsetHelper.deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); await ( await offsetHelper.withdraw( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); const postWithdrawPoolTokenBalance = await poolToken .token() - .balanceOf(addr2.address); + .balanceOf(owner.address); expect(formatEther(postWithdrawPoolTokenBalance)).to.be.eql( formatEther(preDepositPoolTokenBalance) @@ -839,21 +909,21 @@ describe("OffsetHelper", function () { await ( await offsetHelper.deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); await expect( offsetHelper.withdraw( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], parseEther("2.0") ) ).to.be.revertedWith("Insufficient balance"); }); it(`should deposit 1.0 ${name.toUpperCase()}`, async function () { - const { offsetHelper, addr2, tokens } = await loadFixture( + const { offsetHelper, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); const poolToken = tokens[name]; @@ -864,7 +934,7 @@ describe("OffsetHelper", function () { await ( await offsetHelper.deposit( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); @@ -872,8 +942,8 @@ describe("OffsetHelper", function () { expect( formatEther( await offsetHelper.balances( - addr2.address, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT + owner.address, + networkPoolAddress[poolToken.name] ) ) ).to.be.eql("1.0"); @@ -883,23 +953,23 @@ describe("OffsetHelper", function () { describe("#swapExactOut{ETH,Token}() for pool token", function () { for (const name of TOKEN_POOLS) { - it(`should swap MATIC for 1.0 ${name.toUpperCase()}`, async function () { + it(`should swap native Token, e.g., MATIC for 1.0 ${name.toUpperCase()}`, async function () { const { offsetHelper, tokens } = await loadFixture( deployOffsetHelperFixture ); const poolToken = tokens[name]; - const maticToSend = await offsetHelper.calculateNeededETHAmount( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + const testTokenToSend = await offsetHelper.calculateNeededETHAmount( + networkPoolAddress[poolToken.name], ONE_ETHER ); await ( await offsetHelper.swapExactOutETH( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER, { - value: maticToSend, + value: testTokenToSend, } ) ).wait(); @@ -908,7 +978,7 @@ describe("OffsetHelper", function () { expect(formatEther(balance)).to.be.eql("1.0"); }); - it(`should send surplus MATIC to user`, async function () { + it(`should send surplus native Token, e.g., MATIC to user`, async function () { const { offsetHelper, tokens } = await loadFixture( deployOffsetHelperFixture ); @@ -918,17 +988,17 @@ describe("OffsetHelper", function () { offsetHelper.address ); - const maticToSend = await offsetHelper.calculateNeededETHAmount( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + const testTokenToSend = await offsetHelper.calculateNeededETHAmount( + networkPoolAddress[poolToken.name], ONE_ETHER ); await ( await offsetHelper.swapExactOutETH( - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkPoolAddress[poolToken.name], ONE_ETHER, { - value: maticToSend.add(parseEther("0.5")), + value: testTokenToSend.add(parseEther("0.5")), } ) ).wait(); @@ -937,8 +1007,8 @@ describe("OffsetHelper", function () { offsetHelper.address ); - // I'm expecting that the OffsetHelper doesn't have extra MATIC - // this check is done to ensure any surplus MATIC has been sent to the user, and not to OffsetHelper + // I'm expecting that the OffsetHelper doesn't have extra native Token, e.g., MATIC + // this check is done to ensure any surplus native Token, e.g., MATIC has been sent to the user, and not to OffsetHelper expect(formatEther(preSwapETHBalance)).to.be.eql( formatEther(postSwapETHBalance) ); @@ -958,15 +1028,15 @@ describe("OffsetHelper", function () { offsetHelper .connect(addrs[0]) .swapExactOutToken( - addresses.WETH, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.WETH, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).to.be.revertedWith("ERC20: transfer amount exceeds balance"); }); it(`should swap WETH for 1.0 ${name.toUpperCase()}`, async function () { - const { offsetHelper, weth, addr2, tokens } = await loadFixture( + const { offsetHelper, weth, owner, tokens } = await loadFixture( deployOffsetHelperFixture ); const poolToken = tokens[name]; @@ -976,8 +1046,8 @@ describe("OffsetHelper", function () { .balanceOf(offsetHelper.address); const neededAmount = await offsetHelper.calculateNeededTokenAmount( - addresses.WETH, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.WETH, + networkPoolAddress[poolToken.name], ONE_ETHER ); @@ -985,8 +1055,8 @@ describe("OffsetHelper", function () { await ( await offsetHelper.swapExactOutToken( - addresses.WETH, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT, + networkAddresses.WETH, + networkPoolAddress[poolToken.name], ONE_ETHER ) ).wait(); @@ -1001,12 +1071,66 @@ describe("OffsetHelper", function () { expect( formatEther( await offsetHelper.balances( - addr2.address, - poolToken.name === "BCT" ? addresses.BCT : addresses.NCT + owner.address, + networkPoolAddress[poolToken.name] ) ) ).to.be.eql("1.0"); }); } }); + + describe("#addPath()", function () { + it(`should add the path to eligibleSwapPaths`, async function () { + const { offsetHelper, owner } = await loadFixture( + deployOffsetHelperFixture + ); + + await offsetHelper.addPath( + "USDT", + [ + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + ], + { + from: owner.address, + } + ); + const path = await offsetHelper.isERC20AddressEligible( + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" + ); + expect(path.length).to.equal(2); + }); + }); + + describe("#removePath()", function () { + it(`should remove the path from eligibleSwapPaths`, async function () { + const { offsetHelper, owner } = await loadFixture( + deployOffsetHelperFixture + ); + + await offsetHelper.addPath( + "USDT", + [ + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + ], + { + from: owner.address, + } + ); + const path1 = await offsetHelper.isERC20AddressEligible( + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" + ); + expect(path1.length).to.equal(2); + + await offsetHelper.removePath("USDT", { + from: owner.address, + }); + const path2 = await offsetHelper.isERC20AddressEligible( + "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" + ); + expect(path2.length).to.equal(0); + }); + }); }); diff --git a/utils/impersonateAccount.ts b/utils/impersonateAccount.ts index b2a996d..eb35b01 100644 --- a/utils/impersonateAccount.ts +++ b/utils/impersonateAccount.ts @@ -1,7 +1,5 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; -import { parseEther } from "ethers/lib/utils"; import { ethers, network } from "hardhat"; -import addresses from "./addresses"; const impersonateAccount = async ( oldAddress: string, From a79cfe81dbf6e32ac877c75ca84dc4ec195ce6ca Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 09:40:55 +0100 Subject: [PATCH 08/12] Deploy new OffsetHelper --- deployments/alfajores/OffsetHelper.json | 1350 ++++++++++++++++ .../9768af37541e90e4200434e6de116099.json | 89 ++ deployments/celo/OffsetHelper.json | 1361 +++++++++++++++++ .../9768af37541e90e4200434e6de116099.json | 89 ++ deployments/mumbai/OffsetHelper.json | 635 +++++--- deployments/mumbai/Swapper.json | 238 +++ .../10fe5cc2e77ff4188aab80798438e159.json | 53 + .../84d45862bdebcae922b40dea008570ca.json | 125 -- .../9768af37541e90e4200434e6de116099.json | 89 ++ deployments/polygon/OffsetHelper.json | 635 +++++--- deployments/polygon/Swapper.json | 238 +++ .../10fe5cc2e77ff4188aab80798438e159.json | 53 + .../84d45862bdebcae922b40dea008570ca.json | 125 -- .../9768af37541e90e4200434e6de116099.json | 89 ++ 14 files changed, 4525 insertions(+), 644 deletions(-) create mode 100644 deployments/alfajores/OffsetHelper.json create mode 100644 deployments/alfajores/solcInputs/9768af37541e90e4200434e6de116099.json create mode 100644 deployments/celo/OffsetHelper.json create mode 100644 deployments/celo/solcInputs/9768af37541e90e4200434e6de116099.json create mode 100644 deployments/mumbai/Swapper.json create mode 100644 deployments/mumbai/solcInputs/10fe5cc2e77ff4188aab80798438e159.json delete mode 100644 deployments/mumbai/solcInputs/84d45862bdebcae922b40dea008570ca.json create mode 100644 deployments/mumbai/solcInputs/9768af37541e90e4200434e6de116099.json create mode 100644 deployments/polygon/Swapper.json create mode 100644 deployments/polygon/solcInputs/10fe5cc2e77ff4188aab80798438e159.json delete mode 100644 deployments/polygon/solcInputs/84d45862bdebcae922b40dea008570ca.json create mode 100644 deployments/polygon/solcInputs/9768af37541e90e4200434e6de116099.json diff --git a/deployments/alfajores/OffsetHelper.json b/deployments/alfajores/OffsetHelper.json new file mode 100644 index 0000000..8d330f4 --- /dev/null +++ b/deployments/alfajores/OffsetHelper.json @@ -0,0 +1,1350 @@ +{ + "address": "0x065C0f397ecb9D904aB65242F41B9484AA9cD9Bf", + "abi": [ + { + "inputs": [ + { + "internalType": "address[]", + "name": "_poolAddresses", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "_tokenSymbolsForPaths", + "type": "string[]" + }, + { + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "poolToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "Redeemed", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + }, + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "name": "addPath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "addPoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "autoOffsetExactInETH", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToSwap", + "type": "uint256" + } + ], + "name": "autoOffsetExactInToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetExactOutETH", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetExactOutToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetPoolToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "autoRedeem", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "autoRetire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balances", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenAmount", + "type": "uint256" + } + ], + "name": "calculateExpectedPoolTokenForETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromAmount", + "type": "uint256" + } + ], + "name": "calculateExpectedPoolTokenForToken", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "calculateNeededETHAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "calculateNeededTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPathsBySymbol", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Address", + "type": "address" + } + ], + "name": "isERC20AddressEligible", + "outputs": [ + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "isPoolAddressEligible", + "outputs": [ + { + "internalType": "bool", + "name": "_isEligible", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "paths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolAddresses", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + } + ], + "name": "removePath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "removePoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "swapExactInETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromAmount", + "type": "uint256" + } + ], + "name": "swapExactInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "swapExactOutETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "swapExactOutToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenSymbolsForPaths", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x7865d0ebb044ab55d08cbe6e5e069c0d4f796effb33d434252b79efdb668bd91", + "receipt": { + "to": null, + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0x065C0f397ecb9D904aB65242F41B9484AA9cD9Bf", + "transactionIndex": 0, + "gasUsed": "4063286", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc2eff75dd41a12b1714499985eefa8bf29d34c2176d873f20c1d1d46c96997a8", + "transactionHash": "0x7865d0ebb044ab55d08cbe6e5e069c0d4f796effb33d434252b79efdb668bd91", + "logs": [], + "blockNumber": 19828368, + "cumulativeGasUsed": "4063286", + "status": 1, + "byzantium": true + }, + "args": [ + [ + "0x4c5f90C50Ca9F849bb75D93a393A4e1B6E68Accb", + "0xfb60a08855389F3c0A66b29aB9eFa911ed5cbCB5" + ], + [ + "mcUSD", + "cUSD", + "CELO" + ], + [ + [ + "0x71DB38719f9113A36e14F409bAD4F07B58b4730b" + ], + [ + "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", + "0x71DB38719f9113A36e14F409bAD4F07B58b4730b" + ], + [ + "0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9", + "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1", + "0x71DB38719f9113A36e14F409bAD4F07B58b4730b" + ] + ], + "0x7D28570135A2B1930F331c507F65039D4937f66c" + ], + "numDeployments": 2, + "solcInputHash": "9768af37541e90e4200434e6de116099", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddresses\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"_tokenSymbolsForPaths\",\"type\":\"string[]\"},{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"name\":\"addPath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"addPoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromTokenAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPathsBySymbol\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Address\",\"type\":\"address\"}],\"name\":\"isERC20AddressEligible\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"isPoolAddressEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_isEligible\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"paths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"removePath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"removePoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tokenSymbolsForPaths\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, e.g., NCT\",\"sender\":\"The sender of the transaction\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}}},\"kind\":\"dev\",\"methods\":{\"addPath(string,address[])\":{\"params\":{\"_path\":\"The path of the path to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"addPoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to add\"}},\"autoOffsetExactInETH(address)\":{\"details\":\"This function is only available on Polygon, not on Celo.\",\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"params\":{\"_fromTokenAmount\":\"The amount of native tokens to swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of native tokens required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_paths\":\"An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.\",\"_poolAddresses\":\"A list of pool token addresses.\",\"_tokenSymbolsForPaths\":\"An array of symbols of the token the user want to retire carbon credits for\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"isERC20AddressEligible(address)\":{\"params\":{\"_erc20Address\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\"},\"returns\":{\"_path\":\"Returns the path of the token to be exchanged\"}},\"isPoolAddressEligible(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"_isEligible\":\"Returns a bool if the Pool token is eligible for offsetting\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"removePath(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the path to remove\"}},\"removePoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to remove\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"swapExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped native tokens .\"}},\"swapExactInToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT.\"}},\"kind\":\"user\",\"methods\":{\"addPath(string,address[])\":{\"notice\":\"Change or add eligible paths and their addresses.\"},\"addPoolToken(address)\":{\"notice\":\"Change or add pool token addresses.\"},\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC.\"},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"isERC20AddressEligible(address)\":{\"notice\":\"Checks if ERC20 Token is eligible for swapping.\"},\"isPoolAddressEligible(address)\":{\"notice\":\"Checks if Pool Address is eligible for offsetting.\"},\"removePath(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"removePoolToken(address)\":{\"notice\":\"Delete eligible pool token addresses stored in the contract.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped.\"},\"swapExactInToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\\n * swap on a DEX).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token e.g., NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n // Chain ID of Celo mainnet\\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token e.g., NCT.\\n *\\n * @param sender The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, e.g., NCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address sender,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Path doesn't yet exists.\\\");\\n\\n _;\\n }\\n\\n modifier nativeTokenChain() {\\n require(\\n block.chainid != CELO_MAINNET_CHAINID,\\n \\\"The function is not available on this network.\\\"\\n );\\n\\n _;\\n }\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _poolAddresses A list of pool token addresses.\\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\\n * to the provided token symbols.\\n */\\n constructor(\\n address[] memory _poolAddresses,\\n string[] memory _tokenSymbolsForPaths,\\n address[][] memory _paths,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n poolAddresses = _poolAddresses;\\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\\n paths = _paths;\\n\\n uint256 i = 0;\\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\\n while (i < eligibleSwapPathsBySymbolLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n // fallback payable and receive method to fix the situation where transfering dust native tokens\\n // in the native tokens to token swap fails\\n\\n receive() external payable {}\\n\\n fallback() external payable {}\\n\\n // ----------------------------------------\\n // Upgradable related functions\\n // ----------------------------------------\\n\\n function initialize() external virtual initializer {\\n __Ownable_init_unchained();\\n }\\n\\n // ----------------------------------------\\n // Public functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\\n * to determine how much native tokens e.g., MATIC must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to offset, e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\\n * can be used to calculate the expected amount of TCO2s that will be\\n * offset using `autoOffsetExactInToken()`.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToSwap\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(\\n _fromToken,\\n _poolToken,\\n _amountToSwap\\n );\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n *\\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\\n * the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\\n * to the user. This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(\\n address _poolToken,\\n uint256 _amountToOffset\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n * All provided native tokens is consumed for offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\\n * used to calculate the expected amount of TCO2s that will be offset\\n * using `autoOffsetExactInETH()`.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, e.g., NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\\n // calculate path & amounts\\n (\\n address[] memory path,\\n uint256[] memory expAmounts\\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(dexRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // calculate path & amounts\\n\\n address[] memory path = generatePath(_fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining native tokens that was not consumed by the swap is returned.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutETH(\\n address _poolToken,\\n uint256 _toAmount\\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\\n // create path & amounts\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided native tokens will be swapped.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped native tokens .\\n */\\n function swapExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // create path & amounts\\n uint256 fromAmount = msg.value;\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(\\n address _erc20Addr,\\n uint256 _amount\\n ) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(\\n address _fromToken,\\n uint256 _amount\\n )\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(\\n address[] memory _tco2s,\\n uint256[] memory _amounts\\n ) public {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n // ----------------------------------------\\n // Public view functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, e.g., NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n _fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n _fromToken,\\n _poolToken,\\n _fromAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, e.g., NCT.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of native tokens required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\\n *\\n * @param _fromTokenAmount The amount of native tokens to swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n address _poolToken,\\n uint256 _fromTokenAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n fromToken,\\n _poolToken,\\n _fromTokenAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Checks if Pool Address is eligible for offsetting.\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\\n */\\n function isPoolAddressEligible(\\n address _poolToken\\n ) public view returns (bool _isEligible) {\\n _isEligible = isRedeemable(_poolToken);\\n }\\n\\n /**\\n * @notice Checks if ERC20 Token is eligible for swapping.\\n * @param _erc20Address The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @return _path Returns the path of the token to be exchanged\\n */\\n function isERC20AddressEligible(\\n address _erc20Address\\n ) public view returns (address[] memory _path) {\\n _path = eligibleSwapPaths[_erc20Address];\\n }\\n\\n // ----------------------------------------\\n // Internal methods\\n // ----------------------------------------\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n /**\\n * @notice Show all pool token addresses that can be used to retired.\\n * @param _fromToken a list of token symbols that can be retired.\\n * @param _toToken a list of token symbols that can be retired.\\n */\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n function dexRouter() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(dexRouterAddress);\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < paths.length; i++) {\\n if (paths[i][0] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Cheks if Pool Token is eligible for Offsetting.\\n * @param _poolToken The addresses of the pool token to redeem\\n * @return _isEligible Returns if token can be redeemed\\n */\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible paths and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _path The path of the path to add\\n */\\n function addPath(\\n string memory _tokenSymbol,\\n address[] memory _path\\n ) public virtual onlyOwner {\\n eligibleSwapPaths[_path[0]] = _path;\\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\\n tokenSymbolsForPaths.push(_tokenSymbol);\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the path to remove\\n */\\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change or add pool token addresses.\\n * @param _poolToken The address of the pool token to add\\n */\\n function addPoolToken(address _poolToken) public virtual onlyOwner {\\n poolAddresses.push(_poolToken);\\n }\\n\\n /**\\n * @notice Delete eligible pool token addresses stored in the contract.\\n * @param _poolToken The address of the pool token to remove\\n */\\n function removePoolToken(address _poolToken) public virtual onlyOwner {\\n for (uint256 i; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _poolToken) {\\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\\n poolAddresses.pop();\\n break;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x00812c8474fe0303b130513d22e4a8cf4866cb16c3a5099203ef3fd769dc1f8a\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(address => address[]) public eligibleSwapPaths;\\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\\n\\n address public dexRouterAddress;\\n\\n address[] public poolAddresses;\\n string[] public tokenSymbolsForPaths;\\n address[][] public paths;\\n\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0xd505f00a17446ca29983779a8febff10114173db7f47ca4300d6a0bfce6b957a\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200416338038062004163833981016040819052620000349162000585565b606780546001600160a01b0319166001600160a01b038316179055835162000064906068906020870190620001fd565b5082516200007a90606990602086019062000267565b5081516200009090606a906020850190620002c7565b5082516000905b80821015620001f157838281518110620000c157634e487b7160e01b600052603260045260246000fd5b602002602001015160656000868581518110620000ee57634e487b7160e01b600052603260045260246000fd5b60200260200101516000815181106200011757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020908051906020019062000154929190620001fd565b508382815181106200017657634e487b7160e01b600052603260045260246000fd5b60200260200101516066868481518110620001a157634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620001b89190620006fc565b90815260200160405180910390209080519060200190620001db929190620001fd565b50620001e960018362000773565b915062000097565b5050505050506200081e565b82805482825590600052602060002090810192821562000255579160200282015b828111156200025557825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200021e565b506200026392915062000327565b5090565b828054828255906000526020600020908101928215620002b9579160200282015b82811115620002b95782518051620002a89184916020909101906200033e565b509160200191906001019062000288565b5062000263929150620003bb565b82805482825590600052602060002090810192821562000319579160200282015b8281111562000319578251805162000308918491602090910190620001fd565b5091602001919060010190620002e8565b5062000263929150620003dc565b5b8082111562000263576000815560010162000328565b8280546200034c90620007cb565b90600052602060002090601f01602090048101928262000370576000855562000255565b82601f106200038b57805160ff191683800117855562000255565b8280016001018555821562000255579182015b82811115620002555782518255916020019190600101906200039e565b8082111562000263576000620003d28282620003fd565b50600101620003bb565b8082111562000263576000620003f382826200043f565b50600101620003dc565b5080546200040b90620007cb565b6000825580601f106200041c575050565b601f0160209004906000526020600020908101906200043c919062000327565b50565b50805460008255906000526020600020908101906200043c919062000327565b80516001600160a01b03811681146200047757600080fd5b919050565b600082601f8301126200048d578081fd5b81516020620004a6620004a0836200074d565b6200071a565b80838252828201915082860187848660051b8901011115620004c6578586fd5b855b85811015620004ef57620004dc826200045f565b84529284019290840190600101620004c8565b5090979650505050505050565b600082601f8301126200050d578081fd5b8151602062000520620004a0836200074d565b80838252828201915082860187848660051b890101111562000540578586fd5b855b85811015620004ef5781516001600160401b0381111562000561578788fd5b620005718a87838c01016200047c565b855250928401929084019060010162000542565b600080600080608085870312156200059b578384fd5b84516001600160401b0380821115620005b2578586fd5b620005c0888389016200047c565b95506020870151915080821115620005d6578485fd5b818701915087601f830112620005ea578485fd5b8151620005fb620004a0826200074d565b80828252602082019150602085018b60208560051b88010111156200061e578889fd5b885b84811015620006b65781518681111562000638578a8bfd5b8701603f81018e1362000649578a8bfd5b60208101518781111562000661576200066162000808565b62000676601f8201601f19166020016200071a565b8181528f60408385010111156200068b578c8dfd5b6200069e82602083016040860162000798565b86525050602093840193919091019060010162000620565b505060408a01519097509350505080821115620006d1578384fd5b50620006e087828801620004fc565b925050620006f1606086016200045f565b905092959194509250565b600082516200071081846020870162000798565b9190910192915050565b604051601f8201601f191681016001600160401b038111828210171562000745576200074562000808565b604052919050565b60006001600160401b0382111562000769576200076962000808565b5060051b60200190565b600082198211156200079357634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620007b55781810151838201526020016200079b565b83811115620007c5576000848401525b50505050565b600181811c90821680620007e057607f821691505b602082108114156200080257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b613935806200082e6000396000f3fe6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "deployedBytecode": "0x6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "devdoc": { + "events": { + "Redeemed(address,address,address[],uint256[])": { + "params": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "poolToken": "The address of the Toucan pool token used in the redemption, e.g., NCT", + "sender": "The sender of the transaction", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + } + }, + "kind": "dev", + "methods": { + "addPath(string,address[])": { + "params": { + "_path": "The path of the path to add", + "_tokenSymbol": "The symbol of the token to add" + } + }, + "addPoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to add" + } + }, + "autoOffsetExactInETH(address)": { + "details": "This function is only available on Polygon, not on Celo.", + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactInToken(address,address,uint256)": { + "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", + "params": { + "_amountToSwap": "The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.", + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactOutETH(address,uint256)": { + "details": "If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.", + "params": { + "_amountToOffset": "The amount of TCO2 to offset.", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactOutToken(address,address,uint256)": { + "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", + "params": { + "_amountToOffset": "The amount of TCO2 to offset", + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the Toucan pool token that the user wants to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetPoolToken(address,uint256)": { + "params": { + "_amountToOffset": "The amount of TCO2 to offset.", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoRedeem(address,uint256)": { + "details": "Needs to be approved on the client side", + "params": { + "_amount": "Amount to redeem", + "_fromToken": "Could be the address of NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoRetire(address[],uint256[])": { + "params": { + "_amounts": "The amounts to retire from each of the corresponding TCO2 addresses", + "_tco2s": "The addresses of the TCO2s to retire" + } + }, + "calculateExpectedPoolTokenForETH(address,uint256)": { + "params": { + "_fromTokenAmount": "The amount of native tokens to swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "The expected amount of Pool token that can be acquired" + } + }, + "calculateExpectedPoolTokenForToken(address,address,uint256)": { + "params": { + "_fromAmount": "The amount of ERC20 token to swap", + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "The expected amount of Pool token that can be acquired" + } + }, + "calculateNeededETHAmount(address,uint256)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" + }, + "returns": { + "amountIn": "The amount of native tokens required in order to swap for the specified amount of the pool token" + } + }, + "calculateNeededTokenAmount(address,address,uint256)": { + "params": { + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" + }, + "returns": { + "amountIn": "The amount of the ERC20 token required in order to swap for the specified amount of the pool token" + } + }, + "constructor": { + "details": "See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.", + "params": { + "_paths": "An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.", + "_poolAddresses": "A list of pool token addresses.", + "_tokenSymbolsForPaths": "An array of symbols of the token the user want to retire carbon credits for" + } + }, + "deposit(address,uint256)": { + "details": "Needs to be approved" + }, + "isERC20AddressEligible(address)": { + "params": { + "_erc20Address": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)" + }, + "returns": { + "_path": "Returns the path of the token to be exchanged" + } + }, + "isPoolAddressEligible(address)": { + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "_isEligible": "Returns a bool if the Pool token is eligible for offsetting" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "removePath(string)": { + "params": { + "_tokenSymbol": "The symbol of the path to remove" + } + }, + "removePoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to remove" + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "swapExactInETH(address)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped native tokens ." + } + }, + "swapExactInToken(address,address,uint256)": { + "details": "Needs to be approved on the client side.", + "params": { + "_fromAmount": "The amount of ERC20 token to swap", + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." + } + }, + "swapExactOutETH(address,uint256)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" + } + }, + "swapExactOutToken(address,address,uint256)": { + "details": "Needs to be approved on the client side", + "params": { + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "Toucan Protocol Offset Helpers", + "version": 1 + }, + "userdoc": { + "events": { + "Redeemed(address,address,address[],uint256[])": { + "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT." + } + }, + "kind": "user", + "methods": { + "addPath(string,address[])": { + "notice": "Change or add eligible paths and their addresses." + }, + "addPoolToken(address)": { + "notice": "Change or add pool token addresses." + }, + "autoOffsetExactInETH(address)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + }, + "autoOffsetExactInToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + }, + "autoOffsetExactOutETH(address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + }, + "autoOffsetExactOutToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + }, + "autoOffsetPoolToken(address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." + }, + "autoRedeem(address,uint256)": { + "notice": "Redeems the specified amount of NCT / BCT for TCO2." + }, + "autoRetire(address[],uint256[])": { + "notice": "Retire the specified TCO2 tokens." + }, + "calculateExpectedPoolTokenForETH(address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC." + }, + "calculateExpectedPoolTokenForToken(address,address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token." + }, + "calculateNeededETHAmount(address,uint256)": { + "notice": "Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT." + }, + "calculateNeededTokenAmount(address,address,uint256)": { + "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT." + }, + "constructor": { + "notice": "Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract." + }, + "deposit(address,uint256)": { + "notice": "Allow users to deposit BCT / NCT." + }, + "isERC20AddressEligible(address)": { + "notice": "Checks if ERC20 Token is eligible for swapping." + }, + "isPoolAddressEligible(address)": { + "notice": "Checks if Pool Address is eligible for offsetting." + }, + "removePath(string)": { + "notice": "Delete eligible tokens stored in the contract." + }, + "removePoolToken(address)": { + "notice": "Delete eligible pool token addresses stored in the contract." + }, + "swapExactInETH(address)": { + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped." + }, + "swapExactInToken(address,address,uint256)": { + "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped." + }, + "swapExactOutETH(address,uint256)": { + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned." + }, + "swapExactOutToken(address,address,uint256)": { + "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap" + }, + "withdraw(address,uint256)": { + "notice": "Allow users to withdraw tokens they have deposited." + } + }, + "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 138, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 141, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 703, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 10, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 130, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 3502, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "eligibleSwapPaths", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" + }, + { + "astId": 3507, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "eligibleSwapPathsBySymbol", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)" + }, + { + "astId": 3509, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "dexRouterAddress", + "offset": 0, + "slot": "103", + "type": "t_address" + }, + { + "astId": 3512, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "poolAddresses", + "offset": 0, + "slot": "104", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 3515, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "tokenSymbolsForPaths", + "offset": 0, + "slot": "105", + "type": "t_array(t_string_storage)dyn_storage" + }, + { + "astId": 3519, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "paths", + "offset": 0, + "slot": "106", + "type": "t_array(t_array(t_address)dyn_storage)dyn_storage" + }, + { + "astId": 3525, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "balances", + "offset": 0, + "slot": "107", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_array(t_address)dyn_storage)dyn_storage": { + "base": "t_array(t_address)dyn_storage", + "encoding": "dynamic_array", + "label": "address[][]", + "numberOfBytes": "32" + }, + "t_array(t_string_storage)dyn_storage": { + "base": "t_string_storage", + "encoding": "dynamic_array", + "label": "string[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "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/alfajores/solcInputs/9768af37541e90e4200434e6de116099.json b/deployments/alfajores/solcInputs/9768af37541e90e4200434e6de116099.json new file mode 100644 index 0000000..0e855da --- /dev/null +++ b/deployments/alfajores/solcInputs/9768af37541e90e4200434e6de116099.json @@ -0,0 +1,89 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\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/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-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/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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanCarbonOffsets.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanContractRegistry.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IToucanPoolToken.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" + }, + "contracts/OffsetHelper.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\n * swap on a DEX).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token e.g., NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n // Chain ID of Celo mainnet\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token e.g., NCT.\n *\n * @param sender The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, e.g., NCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address sender,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Path doesn't yet exists.\");\n\n _;\n }\n\n modifier nativeTokenChain() {\n require(\n block.chainid != CELO_MAINNET_CHAINID,\n \"The function is not available on this network.\"\n );\n\n _;\n }\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _poolAddresses A list of pool token addresses.\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\n * to the provided token symbols.\n */\n constructor(\n address[] memory _poolAddresses,\n string[] memory _tokenSymbolsForPaths,\n address[][] memory _paths,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n poolAddresses = _poolAddresses;\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\n paths = _paths;\n\n uint256 i = 0;\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\n while (i < eligibleSwapPathsBySymbolLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\n i += 1;\n }\n }\n\n // fallback payable and receive method to fix the situation where transfering dust native tokens\n // in the native tokens to token swap fails\n\n receive() external payable {}\n\n fallback() external payable {}\n\n // ----------------------------------------\n // Upgradable related functions\n // ----------------------------------------\n\n function initialize() external virtual initializer {\n __Ownable_init_unchained();\n }\n\n // ----------------------------------------\n // Public functions\n // ----------------------------------------\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\n * to determine how much native tokens e.g., MATIC must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to offset, e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\n * can be used to calculate the expected amount of TCO2s that will be\n * offset using `autoOffsetExactInToken()`.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToSwap\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(\n _fromToken,\n _poolToken,\n _amountToSwap\n );\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n *\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\n * the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\n * to the user. This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(\n address _poolToken,\n uint256 _amountToOffset\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n * All provided native tokens is consumed for offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\n * used to calculate the expected amount of TCO2s that will be offset\n * using `autoOffsetExactInETH()`.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, e.g., NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\n // calculate path & amounts\n (\n address[] memory path,\n uint256[] memory expAmounts\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(dexRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // calculate path & amounts\n\n address[] memory path = generatePath(_fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining native tokens that was not consumed by the swap is returned.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutETH(\n address _poolToken,\n uint256 _toAmount\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\n // create path & amounts\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n // swap\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided native tokens will be swapped.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped native tokens .\n */\n function swapExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // create path & amounts\n uint256 fromAmount = msg.value;\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(\n address _erc20Addr,\n uint256 _amount\n ) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(\n address _fromToken,\n uint256 _amount\n )\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(\n address[] memory _tco2s,\n uint256[] memory _amounts\n ) public {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n // ----------------------------------------\n // Public view functions\n // ----------------------------------------\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, e.g., NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n (, uint256[] memory amounts) = calculateExactOutSwap(\n _fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n (, uint256[] memory amounts) = calculateExactInSwap(\n _fromToken,\n _poolToken,\n _fromAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, e.g., NCT.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of native tokens required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactOutSwap(\n fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\n *\n * @param _fromTokenAmount The amount of native tokens to swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n address _poolToken,\n uint256 _fromTokenAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactInSwap(\n fromToken,\n _poolToken,\n _fromTokenAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Checks if Pool Address is eligible for offsetting.\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\n */\n function isPoolAddressEligible(\n address _poolToken\n ) public view returns (bool _isEligible) {\n _isEligible = isRedeemable(_poolToken);\n }\n\n /**\n * @notice Checks if ERC20 Token is eligible for swapping.\n * @param _erc20Address The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @return _path Returns the path of the token to be exchanged\n */\n function isERC20AddressEligible(\n address _erc20Address\n ) public view returns (address[] memory _path) {\n _path = eligibleSwapPaths[_erc20Address];\n }\n\n // ----------------------------------------\n // Internal methods\n // ----------------------------------------\n\n function calculateExactOutSwap(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n /**\n * @notice Show all pool token addresses that can be used to retired.\n * @param _fromToken a list of token symbols that can be retired.\n * @param _toToken a list of token symbols that can be retired.\n */\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n function dexRouter() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(dexRouterAddress);\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < paths.length; i++) {\n if (paths[i][0] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Cheks if Pool Token is eligible for Offsetting.\n * @param _poolToken The addresses of the pool token to redeem\n * @return _isEligible Returns if token can be redeemed\n */\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible paths and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _path The path of the path to add\n */\n function addPath(\n string memory _tokenSymbol,\n address[] memory _path\n ) public virtual onlyOwner {\n eligibleSwapPaths[_path[0]] = _path;\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\n tokenSymbolsForPaths.push(_tokenSymbol);\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the path to remove\n */\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\n }\n\n /**\n * @notice Change or add pool token addresses.\n * @param _poolToken The address of the pool token to add\n */\n function addPoolToken(address _poolToken) public virtual onlyOwner {\n poolAddresses.push(_poolToken);\n }\n\n /**\n * @notice Delete eligible pool token addresses stored in the contract.\n * @param _poolToken The address of the pool token to remove\n */\n function removePoolToken(address _poolToken) public virtual onlyOwner {\n for (uint256 i; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _poolToken) {\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\n poolAddresses.pop();\n break;\n }\n }\n }\n}\n" + }, + "contracts/OffsetHelperStorage.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(address => address[]) public eligibleSwapPaths;\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\n\n address public dexRouterAddress;\n\n address[] public poolAddresses;\n string[] public tokenSymbolsForPaths;\n address[][] public paths;\n\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" + }, + "contracts/types/CarbonProjectTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" + }, + "contracts/types/CarbonProjectVintageTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/celo/OffsetHelper.json b/deployments/celo/OffsetHelper.json new file mode 100644 index 0000000..63e50da --- /dev/null +++ b/deployments/celo/OffsetHelper.json @@ -0,0 +1,1361 @@ +{ + "address": "0xBf91931336f89E5DBdBd60dA757bDf9D2D14dd6B", + "abi": [ + { + "inputs": [ + { + "internalType": "address[]", + "name": "_poolAddresses", + "type": "address[]" + }, + { + "internalType": "string[]", + "name": "_tokenSymbolsForPaths", + "type": "string[]" + }, + { + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "poolToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "Redeemed", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + }, + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "name": "addPath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "addPoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "autoOffsetExactInETH", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToSwap", + "type": "uint256" + } + ], + "name": "autoOffsetExactInToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetExactOutETH", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetExactOutToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToOffset", + "type": "uint256" + } + ], + "name": "autoOffsetPoolToken", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "autoRedeem", + "outputs": [ + { + "internalType": "address[]", + "name": "tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tco2s", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "autoRetire", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balances", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenAmount", + "type": "uint256" + } + ], + "name": "calculateExpectedPoolTokenForETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromAmount", + "type": "uint256" + } + ], + "name": "calculateExpectedPoolTokenForToken", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "calculateNeededETHAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "calculateNeededTokenAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPathsBySymbol", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Address", + "type": "address" + } + ], + "name": "isERC20AddressEligible", + "outputs": [ + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "isPoolAddressEligible", + "outputs": [ + { + "internalType": "bool", + "name": "_isEligible", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "paths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolAddresses", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + } + ], + "name": "removePath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "removePoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "swapExactInETH", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromAmount", + "type": "uint256" + } + ], + "name": "swapExactInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "swapExactOutETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_fromToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_toAmount", + "type": "uint256" + } + ], + "name": "swapExactOutToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenSymbolsForPaths", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xdd64a6cd0144188d5efccbabc0246330de3250b33e9bbad8c50861a135033b5d", + "receipt": { + "to": null, + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0xBf91931336f89E5DBdBd60dA757bDf9D2D14dd6B", + "transactionIndex": 3, + "gasUsed": "4507499", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x063543a45be9629aafd00f16515a4791119c1c82f9faddb2d661ade7710a14c9", + "transactionHash": "0xdd64a6cd0144188d5efccbabc0246330de3250b33e9bbad8c50861a135033b5d", + "logs": [], + "blockNumber": 21371309, + "cumulativeGasUsed": "4843006", + "status": 1, + "byzantium": true + }, + "args": [ + [ + "0x0CcB0071e8B8B716A2a5998aB4d97b83790873Fe", + "0x02De4766C272abc10Bc88c220D214A26960a7e92" + ], + [ + "mcUSD", + "cUSD", + "CELO", + "WETH", + "USDC" + ], + [ + [ + "0x918146359264c492bd6934071c6bd31c854edbc3" + ], + [ + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3" + ], + [ + "0x471EcE3750Da237f93B8E339c536989b8978a438", + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3" + ], + [ + "0x122013fd7dF1C6F636a5bb8f03108E876548b455", + "0x918146359264c492bd6934071c6bd31c854edbc3" + ], + [ + "0xef4229c8c3250C675F21BCefa42f58EfbfF6002a", + "0x765DE816845861e75A25fCA122bb6898B8B1282a", + "0x918146359264c492bd6934071c6bd31c854edbc3" + ] + ], + "0x7D28570135A2B1930F331c507F65039D4937f66c" + ], + "numDeployments": 6, + "solcInputHash": "9768af37541e90e4200434e6de116099", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddresses\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"_tokenSymbolsForPaths\",\"type\":\"string[]\"},{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"name\":\"addPath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"addPoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromTokenAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPathsBySymbol\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Address\",\"type\":\"address\"}],\"name\":\"isERC20AddressEligible\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"isPoolAddressEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_isEligible\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"paths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"removePath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"removePoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tokenSymbolsForPaths\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, e.g., NCT\",\"sender\":\"The sender of the transaction\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}}},\"kind\":\"dev\",\"methods\":{\"addPath(string,address[])\":{\"params\":{\"_path\":\"The path of the path to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"addPoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to add\"}},\"autoOffsetExactInETH(address)\":{\"details\":\"This function is only available on Polygon, not on Celo.\",\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"params\":{\"_fromTokenAmount\":\"The amount of native tokens to swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of native tokens required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_paths\":\"An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.\",\"_poolAddresses\":\"A list of pool token addresses.\",\"_tokenSymbolsForPaths\":\"An array of symbols of the token the user want to retire carbon credits for\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"isERC20AddressEligible(address)\":{\"params\":{\"_erc20Address\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\"},\"returns\":{\"_path\":\"Returns the path of the token to be exchanged\"}},\"isPoolAddressEligible(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"_isEligible\":\"Returns a bool if the Pool token is eligible for offsetting\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"removePath(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the path to remove\"}},\"removePoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to remove\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"swapExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped native tokens .\"}},\"swapExactInToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT.\"}},\"kind\":\"user\",\"methods\":{\"addPath(string,address[])\":{\"notice\":\"Change or add eligible paths and their addresses.\"},\"addPoolToken(address)\":{\"notice\":\"Change or add pool token addresses.\"},\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC.\"},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"isERC20AddressEligible(address)\":{\"notice\":\"Checks if ERC20 Token is eligible for swapping.\"},\"isPoolAddressEligible(address)\":{\"notice\":\"Checks if Pool Address is eligible for offsetting.\"},\"removePath(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"removePoolToken(address)\":{\"notice\":\"Delete eligible pool token addresses stored in the contract.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped.\"},\"swapExactInToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\\n * swap on a DEX).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token e.g., NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n // Chain ID of Celo mainnet\\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token e.g., NCT.\\n *\\n * @param sender The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, e.g., NCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address sender,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Path doesn't yet exists.\\\");\\n\\n _;\\n }\\n\\n modifier nativeTokenChain() {\\n require(\\n block.chainid != CELO_MAINNET_CHAINID,\\n \\\"The function is not available on this network.\\\"\\n );\\n\\n _;\\n }\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _poolAddresses A list of pool token addresses.\\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\\n * to the provided token symbols.\\n */\\n constructor(\\n address[] memory _poolAddresses,\\n string[] memory _tokenSymbolsForPaths,\\n address[][] memory _paths,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n poolAddresses = _poolAddresses;\\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\\n paths = _paths;\\n\\n uint256 i = 0;\\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\\n while (i < eligibleSwapPathsBySymbolLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n // fallback payable and receive method to fix the situation where transfering dust native tokens\\n // in the native tokens to token swap fails\\n\\n receive() external payable {}\\n\\n fallback() external payable {}\\n\\n // ----------------------------------------\\n // Upgradable related functions\\n // ----------------------------------------\\n\\n function initialize() external virtual initializer {\\n __Ownable_init_unchained();\\n }\\n\\n // ----------------------------------------\\n // Public functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\\n * to determine how much native tokens e.g., MATIC must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to offset, e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\\n * can be used to calculate the expected amount of TCO2s that will be\\n * offset using `autoOffsetExactInToken()`.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToSwap\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(\\n _fromToken,\\n _poolToken,\\n _amountToSwap\\n );\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n *\\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\\n * the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\\n * to the user. This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(\\n address _poolToken,\\n uint256 _amountToOffset\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n * All provided native tokens is consumed for offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\\n * used to calculate the expected amount of TCO2s that will be offset\\n * using `autoOffsetExactInETH()`.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, e.g., NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\\n // calculate path & amounts\\n (\\n address[] memory path,\\n uint256[] memory expAmounts\\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(dexRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // calculate path & amounts\\n\\n address[] memory path = generatePath(_fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining native tokens that was not consumed by the swap is returned.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutETH(\\n address _poolToken,\\n uint256 _toAmount\\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\\n // create path & amounts\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided native tokens will be swapped.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped native tokens .\\n */\\n function swapExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // create path & amounts\\n uint256 fromAmount = msg.value;\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(\\n address _erc20Addr,\\n uint256 _amount\\n ) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(\\n address _fromToken,\\n uint256 _amount\\n )\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(\\n address[] memory _tco2s,\\n uint256[] memory _amounts\\n ) public {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n // ----------------------------------------\\n // Public view functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, e.g., NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n _fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n _fromToken,\\n _poolToken,\\n _fromAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, e.g., NCT.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of native tokens required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\\n *\\n * @param _fromTokenAmount The amount of native tokens to swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n address _poolToken,\\n uint256 _fromTokenAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n fromToken,\\n _poolToken,\\n _fromTokenAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Checks if Pool Address is eligible for offsetting.\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\\n */\\n function isPoolAddressEligible(\\n address _poolToken\\n ) public view returns (bool _isEligible) {\\n _isEligible = isRedeemable(_poolToken);\\n }\\n\\n /**\\n * @notice Checks if ERC20 Token is eligible for swapping.\\n * @param _erc20Address The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @return _path Returns the path of the token to be exchanged\\n */\\n function isERC20AddressEligible(\\n address _erc20Address\\n ) public view returns (address[] memory _path) {\\n _path = eligibleSwapPaths[_erc20Address];\\n }\\n\\n // ----------------------------------------\\n // Internal methods\\n // ----------------------------------------\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n /**\\n * @notice Show all pool token addresses that can be used to retired.\\n * @param _fromToken a list of token symbols that can be retired.\\n * @param _toToken a list of token symbols that can be retired.\\n */\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n function dexRouter() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(dexRouterAddress);\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < paths.length; i++) {\\n if (paths[i][0] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Cheks if Pool Token is eligible for Offsetting.\\n * @param _poolToken The addresses of the pool token to redeem\\n * @return _isEligible Returns if token can be redeemed\\n */\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible paths and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _path The path of the path to add\\n */\\n function addPath(\\n string memory _tokenSymbol,\\n address[] memory _path\\n ) public virtual onlyOwner {\\n eligibleSwapPaths[_path[0]] = _path;\\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\\n tokenSymbolsForPaths.push(_tokenSymbol);\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the path to remove\\n */\\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change or add pool token addresses.\\n * @param _poolToken The address of the pool token to add\\n */\\n function addPoolToken(address _poolToken) public virtual onlyOwner {\\n poolAddresses.push(_poolToken);\\n }\\n\\n /**\\n * @notice Delete eligible pool token addresses stored in the contract.\\n * @param _poolToken The address of the pool token to remove\\n */\\n function removePoolToken(address _poolToken) public virtual onlyOwner {\\n for (uint256 i; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _poolToken) {\\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\\n poolAddresses.pop();\\n break;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x00812c8474fe0303b130513d22e4a8cf4866cb16c3a5099203ef3fd769dc1f8a\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(address => address[]) public eligibleSwapPaths;\\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\\n\\n address public dexRouterAddress;\\n\\n address[] public poolAddresses;\\n string[] public tokenSymbolsForPaths;\\n address[][] public paths;\\n\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0xd505f00a17446ca29983779a8febff10114173db7f47ca4300d6a0bfce6b957a\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200416338038062004163833981016040819052620000349162000585565b606780546001600160a01b0319166001600160a01b038316179055835162000064906068906020870190620001fd565b5082516200007a90606990602086019062000267565b5081516200009090606a906020850190620002c7565b5082516000905b80821015620001f157838281518110620000c157634e487b7160e01b600052603260045260246000fd5b602002602001015160656000868581518110620000ee57634e487b7160e01b600052603260045260246000fd5b60200260200101516000815181106200011757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020908051906020019062000154929190620001fd565b508382815181106200017657634e487b7160e01b600052603260045260246000fd5b60200260200101516066868481518110620001a157634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620001b89190620006fc565b90815260200160405180910390209080519060200190620001db929190620001fd565b50620001e960018362000773565b915062000097565b5050505050506200081e565b82805482825590600052602060002090810192821562000255579160200282015b828111156200025557825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200021e565b506200026392915062000327565b5090565b828054828255906000526020600020908101928215620002b9579160200282015b82811115620002b95782518051620002a89184916020909101906200033e565b509160200191906001019062000288565b5062000263929150620003bb565b82805482825590600052602060002090810192821562000319579160200282015b8281111562000319578251805162000308918491602090910190620001fd565b5091602001919060010190620002e8565b5062000263929150620003dc565b5b8082111562000263576000815560010162000328565b8280546200034c90620007cb565b90600052602060002090601f01602090048101928262000370576000855562000255565b82601f106200038b57805160ff191683800117855562000255565b8280016001018555821562000255579182015b82811115620002555782518255916020019190600101906200039e565b8082111562000263576000620003d28282620003fd565b50600101620003bb565b8082111562000263576000620003f382826200043f565b50600101620003dc565b5080546200040b90620007cb565b6000825580601f106200041c575050565b601f0160209004906000526020600020908101906200043c919062000327565b50565b50805460008255906000526020600020908101906200043c919062000327565b80516001600160a01b03811681146200047757600080fd5b919050565b600082601f8301126200048d578081fd5b81516020620004a6620004a0836200074d565b6200071a565b80838252828201915082860187848660051b8901011115620004c6578586fd5b855b85811015620004ef57620004dc826200045f565b84529284019290840190600101620004c8565b5090979650505050505050565b600082601f8301126200050d578081fd5b8151602062000520620004a0836200074d565b80838252828201915082860187848660051b890101111562000540578586fd5b855b85811015620004ef5781516001600160401b0381111562000561578788fd5b620005718a87838c01016200047c565b855250928401929084019060010162000542565b600080600080608085870312156200059b578384fd5b84516001600160401b0380821115620005b2578586fd5b620005c0888389016200047c565b95506020870151915080821115620005d6578485fd5b818701915087601f830112620005ea578485fd5b8151620005fb620004a0826200074d565b80828252602082019150602085018b60208560051b88010111156200061e578889fd5b885b84811015620006b65781518681111562000638578a8bfd5b8701603f81018e1362000649578a8bfd5b60208101518781111562000661576200066162000808565b62000676601f8201601f19166020016200071a565b8181528f60408385010111156200068b578c8dfd5b6200069e82602083016040860162000798565b86525050602093840193919091019060010162000620565b505060408a01519097509350505080821115620006d1578384fd5b50620006e087828801620004fc565b925050620006f1606086016200045f565b905092959194509250565b600082516200071081846020870162000798565b9190910192915050565b604051601f8201601f191681016001600160401b038111828210171562000745576200074562000808565b604052919050565b60006001600160401b0382111562000769576200076962000808565b5060051b60200190565b600082198211156200079357634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620007b55781810151838201526020016200079b565b83811115620007c5576000848401525b50505050565b600181811c90821680620007e057607f821691505b602082108114156200080257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b613935806200082e6000396000f3fe6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "deployedBytecode": "0x6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "devdoc": { + "events": { + "Redeemed(address,address,address[],uint256[])": { + "params": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "poolToken": "The address of the Toucan pool token used in the redemption, e.g., NCT", + "sender": "The sender of the transaction", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + } + }, + "kind": "dev", + "methods": { + "addPath(string,address[])": { + "params": { + "_path": "The path of the path to add", + "_tokenSymbol": "The symbol of the token to add" + } + }, + "addPoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to add" + } + }, + "autoOffsetExactInETH(address)": { + "details": "This function is only available on Polygon, not on Celo.", + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactInToken(address,address,uint256)": { + "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", + "params": { + "_amountToSwap": "The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.", + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactOutETH(address,uint256)": { + "details": "If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.", + "params": { + "_amountToOffset": "The amount of TCO2 to offset.", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetExactOutToken(address,address,uint256)": { + "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", + "params": { + "_amountToOffset": "The amount of TCO2 to offset", + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the Toucan pool token that the user wants to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoOffsetPoolToken(address,uint256)": { + "params": { + "_amountToOffset": "The amount of TCO2 to offset.", + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoRedeem(address,uint256)": { + "details": "Needs to be approved on the client side", + "params": { + "_amount": "Amount to redeem", + "_fromToken": "Could be the address of NCT" + }, + "returns": { + "amounts": "An array of the amounts of each TCO2 that were redeemed", + "tco2s": "An array of the TCO2 addresses that were redeemed" + } + }, + "autoRetire(address[],uint256[])": { + "params": { + "_amounts": "The amounts to retire from each of the corresponding TCO2 addresses", + "_tco2s": "The addresses of the TCO2s to retire" + } + }, + "calculateExpectedPoolTokenForETH(address,uint256)": { + "params": { + "_fromTokenAmount": "The amount of native tokens to swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "The expected amount of Pool token that can be acquired" + } + }, + "calculateExpectedPoolTokenForToken(address,address,uint256)": { + "params": { + "_fromAmount": "The amount of ERC20 token to swap", + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "The expected amount of Pool token that can be acquired" + } + }, + "calculateNeededETHAmount(address,uint256)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" + }, + "returns": { + "amountIn": "The amount of native tokens required in order to swap for the specified amount of the pool token" + } + }, + "calculateNeededTokenAmount(address,address,uint256)": { + "params": { + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" + }, + "returns": { + "amountIn": "The amount of the ERC20 token required in order to swap for the specified amount of the pool token" + } + }, + "constructor": { + "details": "See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.", + "params": { + "_paths": "An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.", + "_poolAddresses": "A list of pool token addresses.", + "_tokenSymbolsForPaths": "An array of symbols of the token the user want to retire carbon credits for" + } + }, + "deposit(address,uint256)": { + "details": "Needs to be approved" + }, + "isERC20AddressEligible(address)": { + "params": { + "_erc20Address": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)" + }, + "returns": { + "_path": "Returns the path of the token to be exchanged" + } + }, + "isPoolAddressEligible(address)": { + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "_isEligible": "Returns a bool if the Pool token is eligible for offsetting" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "removePath(string)": { + "params": { + "_tokenSymbol": "The symbol of the path to remove" + } + }, + "removePoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to remove" + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "swapExactInETH(address)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped native tokens ." + } + }, + "swapExactInToken(address,address,uint256)": { + "details": "Needs to be approved on the client side.", + "params": { + "_fromAmount": "The amount of ERC20 token to swap", + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" + }, + "returns": { + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." + } + }, + "swapExactOutETH(address,uint256)": { + "params": { + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" + } + }, + "swapExactOutToken(address,address,uint256)": { + "details": "Needs to be approved on the client side", + "params": { + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "Toucan Protocol Offset Helpers", + "version": 1 + }, + "userdoc": { + "events": { + "Redeemed(address,address,address[],uint256[])": { + "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT." + } + }, + "kind": "user", + "methods": { + "addPath(string,address[])": { + "notice": "Change or add eligible paths and their addresses." + }, + "addPoolToken(address)": { + "notice": "Change or add pool token addresses." + }, + "autoOffsetExactInETH(address)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + }, + "autoOffsetExactInToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + }, + "autoOffsetExactOutETH(address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + }, + "autoOffsetExactOutToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + }, + "autoOffsetPoolToken(address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." + }, + "autoRedeem(address,uint256)": { + "notice": "Redeems the specified amount of NCT / BCT for TCO2." + }, + "autoRetire(address[],uint256[])": { + "notice": "Retire the specified TCO2 tokens." + }, + "calculateExpectedPoolTokenForETH(address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC." + }, + "calculateExpectedPoolTokenForToken(address,address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token." + }, + "calculateNeededETHAmount(address,uint256)": { + "notice": "Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT." + }, + "calculateNeededTokenAmount(address,address,uint256)": { + "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT." + }, + "constructor": { + "notice": "Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract." + }, + "deposit(address,uint256)": { + "notice": "Allow users to deposit BCT / NCT." + }, + "isERC20AddressEligible(address)": { + "notice": "Checks if ERC20 Token is eligible for swapping." + }, + "isPoolAddressEligible(address)": { + "notice": "Checks if Pool Address is eligible for offsetting." + }, + "removePath(string)": { + "notice": "Delete eligible tokens stored in the contract." + }, + "removePoolToken(address)": { + "notice": "Delete eligible pool token addresses stored in the contract." + }, + "swapExactInETH(address)": { + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped." + }, + "swapExactInToken(address,address,uint256)": { + "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped." + }, + "swapExactOutETH(address,uint256)": { + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned." + }, + "swapExactOutToken(address,address,uint256)": { + "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap" + }, + "withdraw(address,uint256)": { + "notice": "Allow users to withdraw tokens they have deposited." + } + }, + "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 138, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8" + }, + { + "astId": 141, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 703, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage" + }, + { + "astId": 10, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address" + }, + { + "astId": 130, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage" + }, + { + "astId": 3502, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "eligibleSwapPaths", + "offset": 0, + "slot": "101", + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" + }, + { + "astId": 3507, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "eligibleSwapPathsBySymbol", + "offset": 0, + "slot": "102", + "type": "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)" + }, + { + "astId": 3509, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "dexRouterAddress", + "offset": 0, + "slot": "103", + "type": "t_address" + }, + { + "astId": 3512, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "poolAddresses", + "offset": 0, + "slot": "104", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 3515, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "tokenSymbolsForPaths", + "offset": 0, + "slot": "105", + "type": "t_array(t_string_storage)dyn_storage" + }, + { + "astId": 3519, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "paths", + "offset": 0, + "slot": "106", + "type": "t_array(t_array(t_address)dyn_storage)dyn_storage" + }, + { + "astId": 3525, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "balances", + "offset": 0, + "slot": "107", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_array(t_address)dyn_storage)dyn_storage": { + "base": "t_array(t_address)dyn_storage", + "encoding": "dynamic_array", + "label": "address[][]", + "numberOfBytes": "32" + }, + "t_array(t_string_storage)dyn_storage": { + "base": "t_string_storage", + "encoding": "dynamic_array", + "label": "string[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)49_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_string_memory_ptr", + "label": "mapping(string => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, + "t_string_memory_ptr": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "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/9768af37541e90e4200434e6de116099.json b/deployments/celo/solcInputs/9768af37541e90e4200434e6de116099.json new file mode 100644 index 0000000..0e855da --- /dev/null +++ b/deployments/celo/solcInputs/9768af37541e90e4200434e6de116099.json @@ -0,0 +1,89 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\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/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-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/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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanCarbonOffsets.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanContractRegistry.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IToucanPoolToken.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" + }, + "contracts/OffsetHelper.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\n * swap on a DEX).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token e.g., NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n // Chain ID of Celo mainnet\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token e.g., NCT.\n *\n * @param sender The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, e.g., NCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address sender,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Path doesn't yet exists.\");\n\n _;\n }\n\n modifier nativeTokenChain() {\n require(\n block.chainid != CELO_MAINNET_CHAINID,\n \"The function is not available on this network.\"\n );\n\n _;\n }\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _poolAddresses A list of pool token addresses.\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\n * to the provided token symbols.\n */\n constructor(\n address[] memory _poolAddresses,\n string[] memory _tokenSymbolsForPaths,\n address[][] memory _paths,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n poolAddresses = _poolAddresses;\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\n paths = _paths;\n\n uint256 i = 0;\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\n while (i < eligibleSwapPathsBySymbolLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\n i += 1;\n }\n }\n\n // fallback payable and receive method to fix the situation where transfering dust native tokens\n // in the native tokens to token swap fails\n\n receive() external payable {}\n\n fallback() external payable {}\n\n // ----------------------------------------\n // Upgradable related functions\n // ----------------------------------------\n\n function initialize() external virtual initializer {\n __Ownable_init_unchained();\n }\n\n // ----------------------------------------\n // Public functions\n // ----------------------------------------\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\n * to determine how much native tokens e.g., MATIC must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to offset, e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\n * can be used to calculate the expected amount of TCO2s that will be\n * offset using `autoOffsetExactInToken()`.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToSwap\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(\n _fromToken,\n _poolToken,\n _amountToSwap\n );\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n *\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\n * the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\n * to the user. This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(\n address _poolToken,\n uint256 _amountToOffset\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n * All provided native tokens is consumed for offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\n * used to calculate the expected amount of TCO2s that will be offset\n * using `autoOffsetExactInETH()`.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, e.g., NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\n // calculate path & amounts\n (\n address[] memory path,\n uint256[] memory expAmounts\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(dexRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // calculate path & amounts\n\n address[] memory path = generatePath(_fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining native tokens that was not consumed by the swap is returned.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutETH(\n address _poolToken,\n uint256 _toAmount\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\n // create path & amounts\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n // swap\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided native tokens will be swapped.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped native tokens .\n */\n function swapExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // create path & amounts\n uint256 fromAmount = msg.value;\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(\n address _erc20Addr,\n uint256 _amount\n ) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(\n address _fromToken,\n uint256 _amount\n )\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(\n address[] memory _tco2s,\n uint256[] memory _amounts\n ) public {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n // ----------------------------------------\n // Public view functions\n // ----------------------------------------\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, e.g., NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n (, uint256[] memory amounts) = calculateExactOutSwap(\n _fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n (, uint256[] memory amounts) = calculateExactInSwap(\n _fromToken,\n _poolToken,\n _fromAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, e.g., NCT.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of native tokens required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactOutSwap(\n fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\n *\n * @param _fromTokenAmount The amount of native tokens to swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n address _poolToken,\n uint256 _fromTokenAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactInSwap(\n fromToken,\n _poolToken,\n _fromTokenAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Checks if Pool Address is eligible for offsetting.\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\n */\n function isPoolAddressEligible(\n address _poolToken\n ) public view returns (bool _isEligible) {\n _isEligible = isRedeemable(_poolToken);\n }\n\n /**\n * @notice Checks if ERC20 Token is eligible for swapping.\n * @param _erc20Address The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @return _path Returns the path of the token to be exchanged\n */\n function isERC20AddressEligible(\n address _erc20Address\n ) public view returns (address[] memory _path) {\n _path = eligibleSwapPaths[_erc20Address];\n }\n\n // ----------------------------------------\n // Internal methods\n // ----------------------------------------\n\n function calculateExactOutSwap(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n /**\n * @notice Show all pool token addresses that can be used to retired.\n * @param _fromToken a list of token symbols that can be retired.\n * @param _toToken a list of token symbols that can be retired.\n */\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n function dexRouter() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(dexRouterAddress);\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < paths.length; i++) {\n if (paths[i][0] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Cheks if Pool Token is eligible for Offsetting.\n * @param _poolToken The addresses of the pool token to redeem\n * @return _isEligible Returns if token can be redeemed\n */\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible paths and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _path The path of the path to add\n */\n function addPath(\n string memory _tokenSymbol,\n address[] memory _path\n ) public virtual onlyOwner {\n eligibleSwapPaths[_path[0]] = _path;\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\n tokenSymbolsForPaths.push(_tokenSymbol);\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the path to remove\n */\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\n }\n\n /**\n * @notice Change or add pool token addresses.\n * @param _poolToken The address of the pool token to add\n */\n function addPoolToken(address _poolToken) public virtual onlyOwner {\n poolAddresses.push(_poolToken);\n }\n\n /**\n * @notice Delete eligible pool token addresses stored in the contract.\n * @param _poolToken The address of the pool token to remove\n */\n function removePoolToken(address _poolToken) public virtual onlyOwner {\n for (uint256 i; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _poolToken) {\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\n poolAddresses.pop();\n break;\n }\n }\n }\n}\n" + }, + "contracts/OffsetHelperStorage.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(address => address[]) public eligibleSwapPaths;\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\n\n address public dexRouterAddress;\n\n address[] public poolAddresses;\n string[] public tokenSymbolsForPaths;\n address[][] public paths;\n\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" + }, + "contracts/types/CarbonProjectTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" + }, + "contracts/types/CarbonProjectVintageTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/mumbai/OffsetHelper.json b/deployments/mumbai/OffsetHelper.json index de55e8c..51e82a8 100644 --- a/deployments/mumbai/OffsetHelper.json +++ b/deployments/mumbai/OffsetHelper.json @@ -1,17 +1,27 @@ { - "address": "0x69C5988BAAAD17C48546c4feEaAADb5bd5F80f58", + "address": "0x9032d9D5Bc552427a698cDb021E6d1DfbbEd3e30", "abi": [ { "inputs": [ + { + "internalType": "address[]", + "name": "_poolAddresses", + "type": "address[]" + }, { "internalType": "string[]", - "name": "_eligibleTokenSymbols", + "name": "_tokenSymbolsForPaths", "type": "string[]" }, { - "internalType": "address[]", - "name": "_eligibleTokenAddresses", - "type": "address[]" + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" } ], "stateMutability": "nonpayable", @@ -55,7 +65,7 @@ { "indexed": false, "internalType": "address", - "name": "who", + "name": "sender", "type": "address" }, { @@ -84,6 +94,37 @@ "stateMutability": "payable", "type": "fallback" }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + }, + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "name": "addPath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "addPoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -115,15 +156,15 @@ "name": "_fromToken", "type": "address" }, - { - "internalType": "uint256", - "name": "_amountToSwap", - "type": "uint256" - }, { "internalType": "address", "name": "_poolToken", "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToSwap", + "type": "uint256" } ], "name": "autoOffsetExactInToken", @@ -175,7 +216,7 @@ "inputs": [ { "internalType": "address", - "name": "_depositedToken", + "name": "_fromToken", "type": "address" }, { @@ -307,22 +348,22 @@ }, { "inputs": [ - { - "internalType": "uint256", - "name": "_fromMaticAmount", - "type": "uint256" - }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenAmount", + "type": "uint256" } ], "name": "calculateExpectedPoolTokenForETH", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -336,22 +377,22 @@ "name": "_fromToken", "type": "address" }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, { "internalType": "uint256", "name": "_fromAmount", "type": "uint256" - }, - { - "internalType": "address", - "name": "_toToken", - "type": "address" } ], "name": "calculateExpectedPoolTokenForToken", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -362,7 +403,7 @@ "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -375,7 +416,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountIn", "type": "uint256" } ], @@ -391,7 +432,7 @@ }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -404,7 +445,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountIn", "type": "uint256" } ], @@ -412,47 +453,58 @@ "type": "function" }, { - "inputs": [], - "name": "contractRegistryAddress", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "_erc20Addr", "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" } ], - "stateMutability": "view", + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ { - "internalType": "string", - "name": "_tokenSymbol", - "type": "string" + "internalType": "address", + "name": "", + "type": "address" } ], - "name": "deleteEligibleTokenAddress", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "_erc20Addr", + "name": "", "type": "address" }, { "internalType": "uint256", - "name": "_amount", + "name": "", "type": "uint256" } ], - "name": "deposit", - "outputs": [], - "stateMutability": "nonpayable", + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", "type": "function" }, { @@ -461,9 +513,14 @@ "internalType": "string", "name": "", "type": "string" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "eligibleTokenAddresses", + "name": "eligibleSwapPathsBySymbol", "outputs": [ { "internalType": "address", @@ -476,73 +533,143 @@ }, { "inputs": [], - "name": "owner", + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Address", + "type": "address" + } + ], + "name": "isERC20AddressEligible", "outputs": [ + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ { "internalType": "address", - "name": "", + "name": "_poolToken", "type": "address" } ], + "name": "isPoolAddressEligible", + "outputs": [ + { + "internalType": "bool", + "name": "_isEligible", + "type": "bool" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", "type": "function" }, { "inputs": [ { - "internalType": "string", - "name": "_tokenSymbol", - "type": "string" + "internalType": "uint256", + "name": "", + "type": "uint256" }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "paths", + "outputs": [ { "internalType": "address", - "name": "_address", + "name": "", "type": "address" } ], - "name": "setEligibleTokenAddress", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolAddresses", + "outputs": [ { "internalType": "address", - "name": "_address", + "name": "", "type": "address" } ], - "name": "setToucanContractRegistry", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + } + ], + "name": "removePath", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "sushiRouterAddress", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "_poolToken", "type": "address" } ], - "stateMutability": "view", + "name": "removePoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" } ], @@ -550,7 +677,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -564,22 +691,22 @@ "name": "_fromToken", "type": "address" }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, { "internalType": "uint256", "name": "_fromAmount", "type": "uint256" - }, - { - "internalType": "address", - "name": "_toToken", - "type": "address" } ], "name": "swapExactInToken", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -590,7 +717,7 @@ "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -613,7 +740,7 @@ }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -627,6 +754,25 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenSymbolsForPaths", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -663,87 +809,108 @@ "type": "receive" } ], - "transactionHash": "0xa54b31df394fbfab53c8ef78bc5e78d95e13207a58fb7de331d0393400bc08c4", + "transactionHash": "0x2a1db3291dd23599ed3dfa9ee0f47f7d46efd61d2bb38389bd2d4bc4c23c6df2", "receipt": { "to": null, - "from": "0x721F6f7A29b99CbdE1F18C4AA7D7AEb31eb2923B", - "contractAddress": "0x69C5988BAAAD17C48546c4feEaAADb5bd5F80f58", - "transactionIndex": 2, - "gasUsed": "2611068", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000804000000000000000000100000000004000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000080000000000040000000200010000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100040000000000000000000000000000000000000000000000000000000000000000000100000", - "blockHash": "0x5562d7bdaf77235f942105a2ca9c884457f1d868563e3b4555a6b89e96762191", - "transactionHash": "0xa54b31df394fbfab53c8ef78bc5e78d95e13207a58fb7de331d0393400bc08c4", + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0x9032d9D5Bc552427a698cDb021E6d1DfbbEd3e30", + "transactionIndex": 13, + "gasUsed": "3996091", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000800000000000000000000100000000000000000000000000000000000000000000000000000000000080000020000000000000000000200000000000000000000000000000000000000000010000000000200000000000000000000000000000000000000000000000000000002000004000000000000000000001000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000100000", + "blockHash": "0x1c97634da442f9fe36e094ee76bf8760231fa00649c9eb56c597d0e08d504133", + "transactionHash": "0x2a1db3291dd23599ed3dfa9ee0f47f7d46efd61d2bb38389bd2d4bc4c23c6df2", "logs": [ { - "transactionIndex": 2, - "blockNumber": 30494385, - "transactionHash": "0xa54b31df394fbfab53c8ef78bc5e78d95e13207a58fb7de331d0393400bc08c4", + "transactionIndex": 13, + "blockNumber": 40037685, + "transactionHash": "0x2a1db3291dd23599ed3dfa9ee0f47f7d46efd61d2bb38389bd2d4bc4c23c6df2", "address": "0x0000000000000000000000000000000000001010", "topics": [ "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x000000000000000000000000721f6f7a29b99cbde1f18c4aa7d7aeb31eb2923b", - "0x000000000000000000000000be188d6641e8b680743a4815dfa0f6208038960f" + "0x000000000000000000000000101b4c436df747b24d17ce43146da52fa6006c36", + "0x00000000000000000000000022b64229c41429a023549fdab3385893b579327a" ], - "data": "0x000000000000000000000000000000000000000000000000000dea20f6efc4000000000000000000000000000000000000000000000000000b14752f9a611d010000000000000000000000000000000000000000000028ad60fd7dd3761845fb0000000000000000000000000000000000000000000000000b068b0ea37159010000000000000000000000000000000000000000000028ad610b67f46d0809fb", - "logIndex": 5, - "blockHash": "0x5562d7bdaf77235f942105a2ca9c884457f1d868563e3b4555a6b89e96762191" + "data": "0x0000000000000000000000000000000000000000000000000020621a62967e66000000000000000000000000000000000000000000000000145ec1ee878287df000000000000000000000000000000000000000000000002ff37634594d3815a000000000000000000000000000000000000000000000000143e5fd424ec0979000000000000000000000000000000000000000000000002ff57c55ff769ffc0", + "logIndex": 120, + "blockHash": "0x1c97634da442f9fe36e094ee76bf8760231fa00649c9eb56c597d0e08d504133" } ], - "blockNumber": 30494385, - "cumulativeGasUsed": "2773481", + "blockNumber": 40037685, + "cumulativeGasUsed": "7890221", "status": 1, "byzantium": true }, "args": [ [ - "BCT", - "NCT", + "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", + "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E" + ], + [ "USDC", "WETH", "WMATIC" ], [ - "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", - "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E", - "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747", - "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", - "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889" - ] + [ + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ], + [ + "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ], + [ + "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ] + ], + "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" ], - "numDeployments": 2, - "solcInputHash": "84d45862bdebcae922b40dea008570ca", - "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string[]\",\"name\":\"_eligibleTokenSymbols\",\"type\":\"string[]\"},{\"internalType\":\"address[]\",\"name\":\"_eligibleTokenAddresses\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"who\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_depositedToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fromMaticAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractRegistryAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"deleteEligibleTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"eligibleTokenAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setEligibleTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setToucanContractRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sushiRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, for example, NCT or BCT\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\",\"who\":\"The sender of the transaction\"}}},\"kind\":\"dev\",\"methods\":{\"autoOffsetExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,uint256,address)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends much MATIC, the leftover amount will be sent back to the user.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_depositedToken\":\"The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(uint256,address)\":{\"params\":{\"_fromMaticAmount\":\"The amount of MATIC to swap\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,uint256,address)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_toAmount\":\"The desired amount of pool token to receive\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"amounts The amount of MATIC required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_toAmount\":\"The desired amount of pool token to receive\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"amountsIn The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_eligibleTokenAddresses\":\"A list of token addresses corresponding to the provided token symbols.\",\"_eligibleTokenSymbols\":\"A list of token symbols.\"}},\"deleteEligibleTokenAddress(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the token to remove\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setEligibleTokenAddress(string,address)\":{\"params\":{\"_address\":\"The address of the token to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"setToucanContractRegistry(address)\":{\"params\":{\"_address\":\"The address of the Toucan contract registry to use\"}},\"swapExactInETH(address)\":{\"params\":{\"_toToken\":\"Token to swap for (will be held within contract)\"},\"returns\":{\"_0\":\"Resulting amount of Toucan pool token that got acquired for the swapped MATIC.\"}},\"swapExactInToken(address,uint256,address)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The ERC20 token to deposit and swap\",\"_toToken\":\"The Toucan token to swap for (will be held within contract)\"},\"returns\":{\"_0\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_toAmount\":\"Amount of NCT / BCT wanted\",\"_toToken\":\"Token to swap for (will be held within contract)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The ERC20 oken to deposit and swap\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\",\"_toToken\":\"The token to swap for (will be held within contract)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token such as BCT or NCT.\"}},\"kind\":\"user\",\"methods\":{\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. All provided MATIC is consumed for offsetting. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,uint256,address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). All provided token is consumed for offsetting. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. Use `calculateNeededETHAmount()` first in order to find out how much MATIC is required to retire the specified quantity of TCO2. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in order to find out how much of the ERC20 token is required to retire the specified quantity of TCO2. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, for example, BCT or NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(uint256,address)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of MATIC.\"},\"calculateExpectedPoolTokenForToken(address,uint256,address)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much MATIC is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deleteEligibleTokenAddress(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"setEligibleTokenAddress(string,address)\":{\"notice\":\"Change or add eligible tokens and their addresses.\"},\"setToucanContractRegistry(address)\":{\"notice\":\"Change the TCO2 contracts registry.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided MATIC will be swapped.\"},\"swapExactInToken(address,uint256,address)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining MATIC that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token swap). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token such as BCT or NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using MATIC, specifying the exact amount of TCO2s to retire, - `autoOffsetExactInETH()` if the user would like to perform a retirement using MATIC, swapping all sent MATIC into TCO2s, - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token\\n * swap).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token such as BCT or NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using MATIC, specifying the exact amount of TCO2s to retire,\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using MATIC, swapping all sent MATIC into TCO2s,\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _eligibleTokenSymbols A list of token symbols.\\n * @param _eligibleTokenAddresses A list of token addresses corresponding\\n * to the provided token symbols.\\n */\\n constructor(\\n string[] memory _eligibleTokenSymbols,\\n address[] memory _eligibleTokenAddresses\\n ) {\\n uint256 i = 0;\\n uint256 eligibleTokenSymbolsLen = _eligibleTokenSymbols.length;\\n while (i < eligibleTokenSymbolsLen) {\\n eligibleTokenAddresses[\\n _eligibleTokenSymbols[i]\\n ] = _eligibleTokenAddresses[i];\\n i += 1;\\n }\\n }\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token such as BCT or NCT.\\n *\\n * @param who The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, for example, NCT or BCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address who,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Token not swappable\\\");\\n\\n _;\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in\\n * order to find out how much of the ERC20 token is required to retire the\\n * specified quantity of TCO2.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _depositedToken The address of the ERC20 token that the user sends\\n * (must be one of USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _depositedToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_depositedToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (must be one of USDC, WETH, WMATIC)\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n uint256 _amountToSwap,\\n address _poolToken\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(_fromToken, _amountToSwap, _poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending MATIC.\\n * Use `calculateNeededETHAmount()` first in order to find out how much\\n * MATIC is required to retire the specified quantity of TCO2.\\n *\\n * This function:\\n * 1. Swaps the Matic sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends much MATIC, the leftover amount will be sent back\\n * to the user.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(address _poolToken, uint256 _amountToOffset)\\n public\\n payable\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap MATIC for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending MATIC.\\n * All provided MATIC is consumed for offsetting.\\n *\\n * This function:\\n * 1. Swaps the Matic sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(address _poolToken)\\n public\\n payable\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap MATIC for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, for example, BCT or NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Checks whether an address can be used by the contract.\\n * @param _erc20Address address of the ERC20 token to be checked\\n * @return True if the address can be used by the contract\\n */\\n function isEligible(address _erc20Address) private view returns (bool) {\\n bool isToucanContract = IToucanContractRegistry(contractRegistryAddress)\\n .checkERC20(_erc20Address);\\n if (isToucanContract) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"BCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"NCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"USDC\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WETH\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WMATIC\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n if (_erc20Address == eligibleTokenAddresses[\\\"USDC\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WETH\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WMATIC\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n if (_erc20Address == eligibleTokenAddresses[\\\"BCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"NCT\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, BCT or NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountsIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount\\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n (, uint256[] memory amounts) =\\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\\n return amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @return The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken\\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n (, uint256[] memory amounts) =\\n calculateExactInSwap(_fromToken, _fromAmount, _toToken);\\n return amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The ERC20 oken to deposit and swap\\n * @param _toToken The token to swap for (will be held within contract)\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) {\\n // calculate path & amounts\\n (address[] memory path, uint256[] memory expAmounts) =\\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(sushiRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(sushiRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_toToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The ERC20 token to deposit and swap\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @param _toToken The Toucan token to swap for (will be held within contract)\\n * @return Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken\\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n // calculate path & amounts\\n address[] memory path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(sushiRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n uint256 amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_toToken] += amountOut;\\n\\n return amountOut;\\n }\\n\\n // apparently I need a fallback and a receive method to fix the situation where transfering dust MATIC\\n // in the MATIC to token swap fails\\n fallback() external payable {}\\n\\n receive() external payable {}\\n\\n /**\\n * @notice Return how much MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, for example, BCT or NCT.\\n *\\n * @param _toToken The address of the pool token to swap for, for\\n * example, NCT or BCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amounts The amount of MATIC required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(address _toToken, uint256 _toAmount)\\n public\\n view\\n onlyRedeemable(_toToken)\\n returns (uint256)\\n {\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n (, uint256[] memory amounts) =\\n calculateExactOutSwap(fromToken, _toToken, _toAmount);\\n return amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of MATIC.\\n *\\n * @param _fromMaticAmount The amount of MATIC to swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @return The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n uint256 _fromMaticAmount,\\n address _toToken\\n ) public view onlyRedeemable(_toToken) returns (uint256) {\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n (, uint256[] memory amounts) =\\n calculateExactInSwap(fromToken, _fromMaticAmount, _toToken);\\n return amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining MATIC that was not consumed by the swap is returned.\\n * @param _toToken Token to swap for (will be held within contract)\\n * @param _toAmount Amount of NCT / BCT wanted\\n */\\n function swapExactOutETH(address _toToken, uint256 _toAmount) public payable onlyRedeemable(_toToken) {\\n // calculate path & amounts\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n address[] memory path = generatePath(fromToken, _toToken);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_toToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided MATIC will be swapped.\\n * @param _toToken Token to swap for (will be held within contract)\\n * @return Resulting amount of Toucan pool token that got acquired for the\\n * swapped MATIC.\\n */\\n function swapExactInETH(address _toToken) public payable onlyRedeemable(_toToken) returns (uint256) {\\n // calculate path & amounts\\n uint256 fromAmount = msg.value;\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n address[] memory path = generatePath(fromToken, _toToken);\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n uint256 amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_toToken] += amountOut;\\n\\n return amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(address _erc20Addr, uint256 _amount) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT or BCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(address _fromToken, uint256 _amount)\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT or BCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(address[] memory _tco2s, uint256[] memory _amounts)\\n public\\n {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount)\\n internal view\\n returns (address[] memory path, uint256[] memory amounts)\\n {\\n path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n amounts = routerSushi().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken)\\n internal view\\n returns (address[] memory path, uint256[] memory amounts)\\n {\\n path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n amounts = routerSushi().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n function generatePath(address _fromToken, address _toToken)\\n internal\\n view\\n returns (address[] memory)\\n {\\n if (_fromToken == eligibleTokenAddresses[\\\"USDC\\\"]) {\\n address[] memory path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n } else {\\n address[] memory path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleTokenAddresses[\\\"USDC\\\"];\\n path[2] = _toToken;\\n return path;\\n }\\n }\\n\\n function routerSushi() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(sushiRouterAddress);\\n }\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible tokens and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _address The address of the token to add\\n */\\n function setEligibleTokenAddress(\\n string memory _tokenSymbol,\\n address _address\\n ) public virtual onlyOwner {\\n eligibleTokenAddresses[_tokenSymbol] = _address;\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the token to remove\\n */\\n function deleteEligibleTokenAddress(string memory _tokenSymbol)\\n public\\n virtual\\n onlyOwner\\n {\\n delete eligibleTokenAddresses[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change the TCO2 contracts registry.\\n * @param _address The address of the Toucan contract registry to use\\n */\\n function setToucanContractRegistry(address _address)\\n public\\n virtual\\n onlyOwner\\n {\\n contractRegistryAddress = _address;\\n }\\n}\\n\",\"keccak256\":\"0xadfd0f60c2669a43127f6d7aa46d17972a7911b706e74cadac7c130246ef4e8f\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(string => address) public eligibleTokenAddresses;\\n address public contractRegistryAddress =\\n 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;\\n address public sushiRouterAddress =\\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0x5238c0c54f0acbcef34bc9a34380b053ddd26580912462b69e54282db9ecded9\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", - "bytecode": "0x6080604052606680546001600160a01b031990811673263fa1c180889b3a3f46330f32a4a23287e99fc91790915560678054909116731b02da8cb0d097eb8d57a175b88c7d8b479975061790553480156200005957600080fd5b5060405162002ef038038062002ef08339810160408190526200007c91620001c8565b81516000905b808210156200013257828281518110620000ac57634e487b7160e01b600052603260045260246000fd5b60200260200101516065858481518110620000d757634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620000ee9190620002ff565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790556200012a60018362000376565b915062000082565b50505050620003e4565b600082601f8301126200014d578081fd5b8151602062000166620001608362000350565b6200031d565b80838252828201915082860187848660051b890101111562000186578586fd5b855b85811015620001bb5781516001600160a01b0381168114620001a8578788fd5b8452928401929084019060010162000188565b5090979650505050505050565b6000806040808486031215620001dc578283fd5b83516001600160401b0380821115620001f3578485fd5b818601915086601f83011262000207578485fd5b815160206200021a620001608362000350565b8083825282820191508286018b848660051b89010111156200023a57898afd5b895b85811015620002ca5781518781111562000254578b8cfd5b8801603f81018e1362000265578b8cfd5b85810151888111156200027c576200027c620003ce565b62000290601f8201601f191688016200031d565b8181528f8c838501011115620002a4578d8efd5b620002b5828983018e86016200039b565b8652505092840192908401906001016200023c565b505091890151919750909450505080831115620002e5578384fd5b5050620002f5858286016200013c565b9150509250929050565b60008251620003138184602087016200039b565b9190910192915050565b604051601f8201601f191681016001600160401b0381118282101715620003485762000348620003ce565b604052919050565b60006001600160401b038211156200036c576200036c620003ce565b5060051b60200190565b600082198211156200039657634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620003b85781810151838201526020016200039e565b83811115620003c8576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b612afc80620003f46000396000f3fe60806040526004361061018b5760003560e01c80638474c288116100e0578063d26bce3911610084578063eee63f2a11610061578063eee63f2a146104b2578063f04ad9d7146104d2578063f2fde38b146104e5578063f3fef3a31461050557005b8063d26bce391461045f578063d8a90c401461047f578063e882e37b1461049257005b8063a0cd6049116100bd578063a0cd6049146103c7578063a59be914146103e7578063c23f001f14610407578063d08ec4751461043f57005b80638474c288146103695780638aef324c146103895780638da5cb5b146103a957005b806347e7ef2411610147578063690c7e3c11610124578063690c7e3c146102f4578063715018a61461031457806379bbce8f1461032957806382155e7e1461034957005b806347e7ef24146102805780635367cd9c146102a05780635d25309d146102b357005b80631109ec99146101945780631661f818146101c75780631a0fdecc146101e7578063226ee4ef146102075780632e98c8141461023557806346af60701461024857005b3661019257005b005b3480156101a057600080fd5b506101b46101af36600461248e565b610525565b6040519081526020015b60405180910390f35b3480156101d357600080fd5b506101926101e23660046124fa565b6105d2565b3480156101f357600080fd5b506101b461020236600461244e565b6108c4565b34801561021357600080fd5b506102276102223660046124b9565b610957565b6040516101be92919061284c565b61022761024336600461248e565b61098b565b34801561025457600080fd5b50606654610268906001600160a01b031681565b6040516001600160a01b0390911681526020016101be565b34801561028c57600080fd5b5061019261029b36600461248e565b6109b8565b6101926102ae36600461248e565b610a30565b3480156102bf57600080fd5b506102686102ce3660046126cc565b80516020818301810180516065825292820191909301209152546001600160a01b031681565b34801561030057600080fd5b506101b461030f3660046124b9565b610c97565b34801561032057600080fd5b50610192610d22565b34801561033557600080fd5b50606754610268906001600160a01b031681565b34801561035557600080fd5b5061022761036436600461248e565b610d36565b34801561037557600080fd5b5061019261038436600461244e565b610fa2565b34801561039557600080fd5b506101b46103a43660046124b9565b611266565b3480156103b557600080fd5b506033546001600160a01b0316610268565b3480156103d357600080fd5b506102276103e236600461244e565b611414565b3480156103f357600080fd5b506101b461040236600461275c565b611443565b34801561041357600080fd5b506101b4610422366004612416565b606860209081526000928352604080842090915290825290205481565b34801561044b57600080fd5b5061022761045a36600461248e565b6114e0565b34801561046b57600080fd5b5061019261047a3660046126ff565b6114ed565b6101b461048d3660046123f3565b611539565b34801561049e57600080fd5b506101926104ad3660046123f3565b6116be565b3480156104be57600080fd5b506101926104cd3660046126cc565b6116e8565b6102276104e03660046123f3565b611720565b3480156104f157600080fd5b506101926105003660046123f3565b61174f565b34801561051157600080fd5b5061019261052036600461248e565b6117c8565b60008261053181611882565b6105565760405162461bcd60e51b815260040161054d9061290f565b60405180910390fd5b600060656040516105739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b03169050600061059b82878761190d565b915050806000815181106105bf57634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b81518061060f5760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b604482015260640161054d565b8151811461062f5760405162461bcd60e51b815260040161054d9061293d565b60005b818110156108be5782818151811061065a57634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561067257600101610632565b82818151811061069257634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106106e157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156107585760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e636500000000000000604482015260640161054d565b82818151811061077857634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106107c757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546107fe9190612a27565b9250508190555083818151811061082557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf5784838151811061085b57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161088191815260200190565b600060405180830381600087803b15801561089b57600080fd5b505af11580156108af573d6000803e3d6000fd5b50505050806001019050610632565b50505050565b6000836108d081611a4d565b6108ec5760405162461bcd60e51b815260040161054d906128e2565b836108f681611882565b6109125760405162461bcd60e51b815260040161054d9061290f565b600061091f87878761190d565b9150508060008151811061094357634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b6060806000610967868686611266565b90506109738482610d36565b909350915061098283836105d2565b50935093915050565b6060806109988484610a30565b6109a28484610d36565b90925090506109b182826105d2565b9250929050565b816109c281611882565b6109de5760405162461bcd60e51b815260040161054d9061290f565b6109f36001600160a01b038416333085611aeb565b3360009081526068602090815260408083206001600160a01b038716845290915281208054849290610a26908490612a0f565b9091555050505050565b81610a3a81611882565b610a565760405162461bcd60e51b815260040161054d9061290f565b60006065604051610a739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b031690506000610a9a8286611b56565b90506000610ab06067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610ae2949392919061287a565b6000604051808303818588803b158015610afb57600080fd5b505af1158015610b0f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b389190810190612679565b905080600081518110610b5b57634e487b7160e01b600052603260045260246000fd5b6020026020010151341115610c5757600081600081518110610b8d57634e487b7160e01b600052603260045260246000fd5b602002602001015134610ba09190612a27565b604080516000808252602082019283905292935033918491610bc1916127f2565b60006040518083038185875af1925050503d8060008114610bfe576040519150601f19603f3d011682016040523d82523d6000602084013e610c03565b606091505b5050905080610c545760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b0000000000604482015260640161054d565b50505b3360009081526068602090815260408083206001600160a01b038a16845290915281208054879290610c8a908490612a0f565b9091555050505050505050565b600083610ca381611a4d565b610cbf5760405162461bcd60e51b815260040161054d906128e2565b82610cc981611882565b610ce55760405162461bcd60e51b815260040161054d9061290f565b6000610cf2878787611d22565b9150508060018251610d049190612a27565b8151811061094357634e487b7160e01b600052603260045260246000fd5b610d2a611e58565b610d346000611eb2565b565b60608083610d4381611882565b610d5f5760405162461bcd60e51b815260040161054d9061290f565b3360009081526068602090815260408083206001600160a01b0389168452909152902054841115610dd25760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e636500000000604482015260640161054d565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b158015610e1657600080fd5b505af1158015610e2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5291908101906125bd565b3360009081526068602090815260408083206001600160a01b038c168452909152812080549397509195508792610e8a908490612a27565b9091555050835160005b81811015610f5a57848181518110610ebc57634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b031681526020019081526020016000206000888481518110610f0b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f429190612a0f565b90915550819050610f5281612a6a565b915050610e94565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b18833888787604051610f90949392919061280e565b60405180910390a15050509250929050565b82610fac81611a4d565b610fc85760405162461bcd60e51b815260040161054d906128e2565b82610fd281611882565b610fee5760405162461bcd60e51b815260040161054d9061290f565b600080610ffc87878761190d565b9150915060008160008151811061102357634e487b7160e01b600052603260045260246000fd5b602090810291909101015190506110456001600160a01b038916333084611aeb565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b15801561109357600080fd5b505af11580156110a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cb91906126ac565b5060006110e06067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161111395949392919061297e565b600060405180830381600087803b15801561112d57600080fd5b505af1158015611141573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111699190810190612679565b9050818160008151811061118d57634e487b7160e01b600052603260045260246000fd5b602002602001015110156112235760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b1580156111e957600080fd5b505af11580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906126ac565b505b3360009081526068602090815260408083206001600160a01b038c16845290915281208054899290611256908490612a0f565b9091555050505050505050505050565b60008361127281611a4d565b61128e5760405162461bcd60e51b815260040161054d906128e2565b8261129881611882565b6112b45760405162461bcd60e51b815260040161054d9061290f565b60006112c08786611b56565b80519091506112da6001600160a01b03891633308a611aeb565b6067546112f4906001600160a01b038a8116911689611f04565b60006113086067546001600160a01b031690565b6001600160a01b03166338ed17398960008630426040518663ffffffff1660e01b815260040161133c95949392919061297e565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113929190810190612679565b90506000816113a2600185612a27565b815181106113c057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038d168352909352918220805491935083929091611401908490612a0f565b90915550909a9950505050505050505050565b606080611422858585610fa2565b61142c8484610d36565b909250905061143b82826105d2565b935093915050565b60008161144f81611882565b61146b5760405162461bcd60e51b815260040161054d9061290f565b600060656040516114889065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b0316905060006114b0828787611d22565b91505080600182516114c29190612a27565b815181106105bf57634e487b7160e01b600052603260045260246000fd5b60608061099884846109b8565b6114f5611e58565b8060658360405161150691906127f2565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790555050565b60008161154581611882565b6115615760405162461bcd60e51b815260040161054d9061290f565b6040805165574d4154494360d01b81526065600682015290519081900360260190205434906001600160a01b0316600061159b8287611b56565b805190915060006115b46067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b81526004016115e7949392919061287a565b6000604051808303818588803b15801561160057600080fd5b505af1158015611614573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261163d9190810190612679565b905060008161164d600185612a27565b8151811061166b57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038e1683529093529182208054919350839290916116ac908490612a0f565b90915550909998505050505050505050565b6116c6611e58565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b6116f0611e58565b60658160405161170091906127f2565b90815260405190819003602001902080546001600160a01b031916905550565b606080600061172e84611539565b905061173a8482610d36565b909350915061174983836105d2565b50915091565b611757611e58565b6001600160a01b0381166117bc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054d565b6117c581611eb2565b50565b3360009081526068602090815260408083206001600160a01b03861684529091529020548111156118325760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161054d565b6118466001600160a01b038316338361202d565b3360009081526068602090815260408083206001600160a01b038616845290915281208054839290611879908490612a27565b90915550505050565b6000606560405161189c90621090d560ea1b815260030190565b908152604051908190036020019020546001600160a01b03838116911614156118c757506001919050565b604051621390d560ea1b81526065906003015b908152604051908190036020019020546001600160a01b038381169116141561190557506001919050565b506000919050565b60608061191a8585611b56565b80519092506119316067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b815260040161195e929190612965565b60006040518083038186803b15801561197657600080fd5b505afa15801561198a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119b29190810190612679565b9150815181146119d45760405162461bcd60e51b815260040161054d9061293d565b816119e0600183612a27565b815181106119fe57634e487b7160e01b600052603260045260246000fd5b602002602001015184146109825760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b604482015260640161054d565b60006065604051611a6890635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0383811691161415611a9357506001919050565b604051630ae8aa8960e31b8152606590600401908152604051908190036020019020546001600160a01b0383811691161415611ad157506001919050565b60405165574d4154494360d01b81526065906006016118da565b6040516001600160a01b03808516602483015283166044820152606481018290526108be9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205d565b60606065604051611b7190635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0384811691161415611c38576040805160028082526060820183526000926020830190803683370190505090508381600081518110611bd757634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611c1957634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101529050611d1c565b60408051600380825260808201909252600091602082016060803683370190505090508381600081518110611c7d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260408051635553444360e01b815260656004820152905190819003602401902054825191169082906001908110611cda57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600281518110611c1957634e487b7160e01b600052603260045260246000fd5b92915050565b606080611d2f8584611b56565b8051909250611d466067546001600160a01b031690565b6001600160a01b031663d06ca61f86856040518363ffffffff1660e01b8152600401611d73929190612965565b60006040518083038186803b158015611d8b57600080fd5b505afa158015611d9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc79190810190612679565b915081518114611de95760405162461bcd60e51b815260040161054d9061293d565b81600081518110611e0a57634e487b7160e01b600052603260045260246000fd5b602002602001015185146109825760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b604482015260640161054d565b6033546001600160a01b03163314610d345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b801580611f8d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f5357600080fd5b505afa158015611f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8b9190612744565b155b611ff85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161054d565b6040516001600160a01b03831660248201526044810182905261202890849063095ea7b360e01b90606401611b1f565b505050565b6040516001600160a01b03831660248201526044810182905261202890849063a9059cbb60e01b90606401611b1f565b60006120b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661212f9092919063ffffffff16565b80519091501561202857808060200190518101906120d091906126ac565b6120285760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054d565b606061213e8484600085612146565b949350505050565b6060824710156121a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161054d565b600080866001600160a01b031685876040516121c391906127f2565b60006040518083038185875af1925050503d8060008114612200576040519150601f19603f3d011682016040523d82523d6000602084013e612205565b606091505b509150915061221687838387612221565b979650505050505050565b6060831561228d578251612286576001600160a01b0385163b6122865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054d565b508161213e565b61213e83838151156122a25781518083602001fd5b8060405162461bcd60e51b815260040161054d91906128af565b600082601f8301126122cc578081fd5b813560206122e16122dc836129eb565b6129ba565b80838252828201915082860187848660051b8901011115612300578586fd5b855b8581101561231e57813584529284019290840190600101612302565b5090979650505050505050565b600082601f83011261233b578081fd5b8151602061234b6122dc836129eb565b80838252828201915082860187848660051b890101111561236a578586fd5b855b8581101561231e5781518452928401929084019060010161236c565b600082601f830112612398578081fd5b813567ffffffffffffffff8111156123b2576123b2612a9b565b6123c5601f8201601f19166020016129ba565b8181528460208386010111156123d9578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612404578081fd5b813561240f81612ab1565b9392505050565b60008060408385031215612428578081fd5b823561243381612ab1565b9150602083013561244381612ab1565b809150509250929050565b600080600060608486031215612462578081fd5b833561246d81612ab1565b9250602084013561247d81612ab1565b929592945050506040919091013590565b600080604083850312156124a0578182fd5b82356124ab81612ab1565b946020939093013593505050565b6000806000606084860312156124cd578283fd5b83356124d881612ab1565b92506020840135915060408401356124ef81612ab1565b809150509250925092565b6000806040838503121561250c578182fd5b823567ffffffffffffffff80821115612523578384fd5b818501915085601f830112612536578384fd5b813560206125466122dc836129eb565b8083825282820191508286018a848660051b8901011115612565578889fd5b8896505b8487101561259057803561257c81612ab1565b835260019690960195918301918301612569565b50965050860135925050808211156125a6578283fd5b506125b3858286016122bc565b9150509250929050565b600080604083850312156125cf578081fd5b825167ffffffffffffffff808211156125e6578283fd5b818501915085601f8301126125f9578283fd5b815160206126096122dc836129eb565b8083825282820191508286018a848660051b8901011115612628578788fd5b8796505b8487101561265357805161263f81612ab1565b83526001969096019591830191830161262c565b509188015191965090935050508082111561266c578283fd5b506125b38582860161232b565b60006020828403121561268a578081fd5b815167ffffffffffffffff8111156126a0578182fd5b61213e8482850161232b565b6000602082840312156126bd578081fd5b8151801515811461240f578182fd5b6000602082840312156126dd578081fd5b813567ffffffffffffffff8111156126f3578182fd5b61213e84828501612388565b60008060408385031215612711578182fd5b823567ffffffffffffffff811115612727578283fd5b61273385828601612388565b925050602083013561244381612ab1565b600060208284031215612755578081fd5b5051919050565b6000806040838503121561276e578182fd5b82359150602083013561244381612ab1565b6000815180845260208085019450808401835b838110156127b85781516001600160a01b031687529582019590820190600101612793565b509495945050505050565b6000815180845260208085019450808401835b838110156127b8578151875295820195908201906001016127d6565b60008251612804818460208701612a3e565b9190910192915050565b6001600160a01b0385811682528416602082015260806040820181905260009061283a90830185612780565b828103606084015261221681856127c3565b60408152600061285f6040830185612780565b828103602084015261287181856127c3565b95945050505050565b8481526080602082015260006128936080830186612780565b6001600160a01b03949094166040830152506060015292915050565b60208152600082518060208401526128ce816040850160208701612a3e565b601f01601f19169190910160400192915050565b602080825260139082015272546f6b656e206e6f7420737761707061626c6560681b604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b82815260406020820152600061213e6040830184612780565b85815284602082015260a06040820152600061299d60a0830186612780565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156129e3576129e3612a9b565b604052919050565b600067ffffffffffffffff821115612a0557612a05612a9b565b5060051b60200190565b60008219821115612a2257612a22612a85565b500190565b600082821015612a3957612a39612a85565b500390565b60005b83811015612a59578181015183820152602001612a41565b838111156108be5750506000910152565b6000600019821415612a7e57612a7e612a85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117c557600080fdfea26469706673582212205049298921bc98c707274355bc30070e8ecc3d64e22e4f8863e106e9963dfd3064736f6c63430008040033", - "deployedBytecode": "0x60806040526004361061018b5760003560e01c80638474c288116100e0578063d26bce3911610084578063eee63f2a11610061578063eee63f2a146104b2578063f04ad9d7146104d2578063f2fde38b146104e5578063f3fef3a31461050557005b8063d26bce391461045f578063d8a90c401461047f578063e882e37b1461049257005b8063a0cd6049116100bd578063a0cd6049146103c7578063a59be914146103e7578063c23f001f14610407578063d08ec4751461043f57005b80638474c288146103695780638aef324c146103895780638da5cb5b146103a957005b806347e7ef2411610147578063690c7e3c11610124578063690c7e3c146102f4578063715018a61461031457806379bbce8f1461032957806382155e7e1461034957005b806347e7ef24146102805780635367cd9c146102a05780635d25309d146102b357005b80631109ec99146101945780631661f818146101c75780631a0fdecc146101e7578063226ee4ef146102075780632e98c8141461023557806346af60701461024857005b3661019257005b005b3480156101a057600080fd5b506101b46101af36600461248e565b610525565b6040519081526020015b60405180910390f35b3480156101d357600080fd5b506101926101e23660046124fa565b6105d2565b3480156101f357600080fd5b506101b461020236600461244e565b6108c4565b34801561021357600080fd5b506102276102223660046124b9565b610957565b6040516101be92919061284c565b61022761024336600461248e565b61098b565b34801561025457600080fd5b50606654610268906001600160a01b031681565b6040516001600160a01b0390911681526020016101be565b34801561028c57600080fd5b5061019261029b36600461248e565b6109b8565b6101926102ae36600461248e565b610a30565b3480156102bf57600080fd5b506102686102ce3660046126cc565b80516020818301810180516065825292820191909301209152546001600160a01b031681565b34801561030057600080fd5b506101b461030f3660046124b9565b610c97565b34801561032057600080fd5b50610192610d22565b34801561033557600080fd5b50606754610268906001600160a01b031681565b34801561035557600080fd5b5061022761036436600461248e565b610d36565b34801561037557600080fd5b5061019261038436600461244e565b610fa2565b34801561039557600080fd5b506101b46103a43660046124b9565b611266565b3480156103b557600080fd5b506033546001600160a01b0316610268565b3480156103d357600080fd5b506102276103e236600461244e565b611414565b3480156103f357600080fd5b506101b461040236600461275c565b611443565b34801561041357600080fd5b506101b4610422366004612416565b606860209081526000928352604080842090915290825290205481565b34801561044b57600080fd5b5061022761045a36600461248e565b6114e0565b34801561046b57600080fd5b5061019261047a3660046126ff565b6114ed565b6101b461048d3660046123f3565b611539565b34801561049e57600080fd5b506101926104ad3660046123f3565b6116be565b3480156104be57600080fd5b506101926104cd3660046126cc565b6116e8565b6102276104e03660046123f3565b611720565b3480156104f157600080fd5b506101926105003660046123f3565b61174f565b34801561051157600080fd5b5061019261052036600461248e565b6117c8565b60008261053181611882565b6105565760405162461bcd60e51b815260040161054d9061290f565b60405180910390fd5b600060656040516105739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b03169050600061059b82878761190d565b915050806000815181106105bf57634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b81518061060f5760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b604482015260640161054d565b8151811461062f5760405162461bcd60e51b815260040161054d9061293d565b60005b818110156108be5782818151811061065a57634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561067257600101610632565b82818151811061069257634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106106e157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156107585760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e636500000000000000604482015260640161054d565b82818151811061077857634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106107c757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546107fe9190612a27565b9250508190555083818151811061082557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf5784838151811061085b57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161088191815260200190565b600060405180830381600087803b15801561089b57600080fd5b505af11580156108af573d6000803e3d6000fd5b50505050806001019050610632565b50505050565b6000836108d081611a4d565b6108ec5760405162461bcd60e51b815260040161054d906128e2565b836108f681611882565b6109125760405162461bcd60e51b815260040161054d9061290f565b600061091f87878761190d565b9150508060008151811061094357634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b6060806000610967868686611266565b90506109738482610d36565b909350915061098283836105d2565b50935093915050565b6060806109988484610a30565b6109a28484610d36565b90925090506109b182826105d2565b9250929050565b816109c281611882565b6109de5760405162461bcd60e51b815260040161054d9061290f565b6109f36001600160a01b038416333085611aeb565b3360009081526068602090815260408083206001600160a01b038716845290915281208054849290610a26908490612a0f565b9091555050505050565b81610a3a81611882565b610a565760405162461bcd60e51b815260040161054d9061290f565b60006065604051610a739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b031690506000610a9a8286611b56565b90506000610ab06067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610ae2949392919061287a565b6000604051808303818588803b158015610afb57600080fd5b505af1158015610b0f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b389190810190612679565b905080600081518110610b5b57634e487b7160e01b600052603260045260246000fd5b6020026020010151341115610c5757600081600081518110610b8d57634e487b7160e01b600052603260045260246000fd5b602002602001015134610ba09190612a27565b604080516000808252602082019283905292935033918491610bc1916127f2565b60006040518083038185875af1925050503d8060008114610bfe576040519150601f19603f3d011682016040523d82523d6000602084013e610c03565b606091505b5050905080610c545760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b0000000000604482015260640161054d565b50505b3360009081526068602090815260408083206001600160a01b038a16845290915281208054879290610c8a908490612a0f565b9091555050505050505050565b600083610ca381611a4d565b610cbf5760405162461bcd60e51b815260040161054d906128e2565b82610cc981611882565b610ce55760405162461bcd60e51b815260040161054d9061290f565b6000610cf2878787611d22565b9150508060018251610d049190612a27565b8151811061094357634e487b7160e01b600052603260045260246000fd5b610d2a611e58565b610d346000611eb2565b565b60608083610d4381611882565b610d5f5760405162461bcd60e51b815260040161054d9061290f565b3360009081526068602090815260408083206001600160a01b0389168452909152902054841115610dd25760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e636500000000604482015260640161054d565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b158015610e1657600080fd5b505af1158015610e2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5291908101906125bd565b3360009081526068602090815260408083206001600160a01b038c168452909152812080549397509195508792610e8a908490612a27565b9091555050835160005b81811015610f5a57848181518110610ebc57634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b031681526020019081526020016000206000888481518110610f0b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f429190612a0f565b90915550819050610f5281612a6a565b915050610e94565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b18833888787604051610f90949392919061280e565b60405180910390a15050509250929050565b82610fac81611a4d565b610fc85760405162461bcd60e51b815260040161054d906128e2565b82610fd281611882565b610fee5760405162461bcd60e51b815260040161054d9061290f565b600080610ffc87878761190d565b9150915060008160008151811061102357634e487b7160e01b600052603260045260246000fd5b602090810291909101015190506110456001600160a01b038916333084611aeb565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b15801561109357600080fd5b505af11580156110a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cb91906126ac565b5060006110e06067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161111395949392919061297e565b600060405180830381600087803b15801561112d57600080fd5b505af1158015611141573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111699190810190612679565b9050818160008151811061118d57634e487b7160e01b600052603260045260246000fd5b602002602001015110156112235760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b1580156111e957600080fd5b505af11580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906126ac565b505b3360009081526068602090815260408083206001600160a01b038c16845290915281208054899290611256908490612a0f565b9091555050505050505050505050565b60008361127281611a4d565b61128e5760405162461bcd60e51b815260040161054d906128e2565b8261129881611882565b6112b45760405162461bcd60e51b815260040161054d9061290f565b60006112c08786611b56565b80519091506112da6001600160a01b03891633308a611aeb565b6067546112f4906001600160a01b038a8116911689611f04565b60006113086067546001600160a01b031690565b6001600160a01b03166338ed17398960008630426040518663ffffffff1660e01b815260040161133c95949392919061297e565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113929190810190612679565b90506000816113a2600185612a27565b815181106113c057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038d168352909352918220805491935083929091611401908490612a0f565b90915550909a9950505050505050505050565b606080611422858585610fa2565b61142c8484610d36565b909250905061143b82826105d2565b935093915050565b60008161144f81611882565b61146b5760405162461bcd60e51b815260040161054d9061290f565b600060656040516114889065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b0316905060006114b0828787611d22565b91505080600182516114c29190612a27565b815181106105bf57634e487b7160e01b600052603260045260246000fd5b60608061099884846109b8565b6114f5611e58565b8060658360405161150691906127f2565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790555050565b60008161154581611882565b6115615760405162461bcd60e51b815260040161054d9061290f565b6040805165574d4154494360d01b81526065600682015290519081900360260190205434906001600160a01b0316600061159b8287611b56565b805190915060006115b46067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b81526004016115e7949392919061287a565b6000604051808303818588803b15801561160057600080fd5b505af1158015611614573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261163d9190810190612679565b905060008161164d600185612a27565b8151811061166b57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038e1683529093529182208054919350839290916116ac908490612a0f565b90915550909998505050505050505050565b6116c6611e58565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b6116f0611e58565b60658160405161170091906127f2565b90815260405190819003602001902080546001600160a01b031916905550565b606080600061172e84611539565b905061173a8482610d36565b909350915061174983836105d2565b50915091565b611757611e58565b6001600160a01b0381166117bc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054d565b6117c581611eb2565b50565b3360009081526068602090815260408083206001600160a01b03861684529091529020548111156118325760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161054d565b6118466001600160a01b038316338361202d565b3360009081526068602090815260408083206001600160a01b038616845290915281208054839290611879908490612a27565b90915550505050565b6000606560405161189c90621090d560ea1b815260030190565b908152604051908190036020019020546001600160a01b03838116911614156118c757506001919050565b604051621390d560ea1b81526065906003015b908152604051908190036020019020546001600160a01b038381169116141561190557506001919050565b506000919050565b60608061191a8585611b56565b80519092506119316067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b815260040161195e929190612965565b60006040518083038186803b15801561197657600080fd5b505afa15801561198a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119b29190810190612679565b9150815181146119d45760405162461bcd60e51b815260040161054d9061293d565b816119e0600183612a27565b815181106119fe57634e487b7160e01b600052603260045260246000fd5b602002602001015184146109825760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b604482015260640161054d565b60006065604051611a6890635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0383811691161415611a9357506001919050565b604051630ae8aa8960e31b8152606590600401908152604051908190036020019020546001600160a01b0383811691161415611ad157506001919050565b60405165574d4154494360d01b81526065906006016118da565b6040516001600160a01b03808516602483015283166044820152606481018290526108be9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205d565b60606065604051611b7190635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0384811691161415611c38576040805160028082526060820183526000926020830190803683370190505090508381600081518110611bd757634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611c1957634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101529050611d1c565b60408051600380825260808201909252600091602082016060803683370190505090508381600081518110611c7d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260408051635553444360e01b815260656004820152905190819003602401902054825191169082906001908110611cda57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600281518110611c1957634e487b7160e01b600052603260045260246000fd5b92915050565b606080611d2f8584611b56565b8051909250611d466067546001600160a01b031690565b6001600160a01b031663d06ca61f86856040518363ffffffff1660e01b8152600401611d73929190612965565b60006040518083038186803b158015611d8b57600080fd5b505afa158015611d9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc79190810190612679565b915081518114611de95760405162461bcd60e51b815260040161054d9061293d565b81600081518110611e0a57634e487b7160e01b600052603260045260246000fd5b602002602001015185146109825760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b604482015260640161054d565b6033546001600160a01b03163314610d345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b801580611f8d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f5357600080fd5b505afa158015611f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8b9190612744565b155b611ff85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161054d565b6040516001600160a01b03831660248201526044810182905261202890849063095ea7b360e01b90606401611b1f565b505050565b6040516001600160a01b03831660248201526044810182905261202890849063a9059cbb60e01b90606401611b1f565b60006120b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661212f9092919063ffffffff16565b80519091501561202857808060200190518101906120d091906126ac565b6120285760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054d565b606061213e8484600085612146565b949350505050565b6060824710156121a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161054d565b600080866001600160a01b031685876040516121c391906127f2565b60006040518083038185875af1925050503d8060008114612200576040519150601f19603f3d011682016040523d82523d6000602084013e612205565b606091505b509150915061221687838387612221565b979650505050505050565b6060831561228d578251612286576001600160a01b0385163b6122865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054d565b508161213e565b61213e83838151156122a25781518083602001fd5b8060405162461bcd60e51b815260040161054d91906128af565b600082601f8301126122cc578081fd5b813560206122e16122dc836129eb565b6129ba565b80838252828201915082860187848660051b8901011115612300578586fd5b855b8581101561231e57813584529284019290840190600101612302565b5090979650505050505050565b600082601f83011261233b578081fd5b8151602061234b6122dc836129eb565b80838252828201915082860187848660051b890101111561236a578586fd5b855b8581101561231e5781518452928401929084019060010161236c565b600082601f830112612398578081fd5b813567ffffffffffffffff8111156123b2576123b2612a9b565b6123c5601f8201601f19166020016129ba565b8181528460208386010111156123d9578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612404578081fd5b813561240f81612ab1565b9392505050565b60008060408385031215612428578081fd5b823561243381612ab1565b9150602083013561244381612ab1565b809150509250929050565b600080600060608486031215612462578081fd5b833561246d81612ab1565b9250602084013561247d81612ab1565b929592945050506040919091013590565b600080604083850312156124a0578182fd5b82356124ab81612ab1565b946020939093013593505050565b6000806000606084860312156124cd578283fd5b83356124d881612ab1565b92506020840135915060408401356124ef81612ab1565b809150509250925092565b6000806040838503121561250c578182fd5b823567ffffffffffffffff80821115612523578384fd5b818501915085601f830112612536578384fd5b813560206125466122dc836129eb565b8083825282820191508286018a848660051b8901011115612565578889fd5b8896505b8487101561259057803561257c81612ab1565b835260019690960195918301918301612569565b50965050860135925050808211156125a6578283fd5b506125b3858286016122bc565b9150509250929050565b600080604083850312156125cf578081fd5b825167ffffffffffffffff808211156125e6578283fd5b818501915085601f8301126125f9578283fd5b815160206126096122dc836129eb565b8083825282820191508286018a848660051b8901011115612628578788fd5b8796505b8487101561265357805161263f81612ab1565b83526001969096019591830191830161262c565b509188015191965090935050508082111561266c578283fd5b506125b38582860161232b565b60006020828403121561268a578081fd5b815167ffffffffffffffff8111156126a0578182fd5b61213e8482850161232b565b6000602082840312156126bd578081fd5b8151801515811461240f578182fd5b6000602082840312156126dd578081fd5b813567ffffffffffffffff8111156126f3578182fd5b61213e84828501612388565b60008060408385031215612711578182fd5b823567ffffffffffffffff811115612727578283fd5b61273385828601612388565b925050602083013561244381612ab1565b600060208284031215612755578081fd5b5051919050565b6000806040838503121561276e578182fd5b82359150602083013561244381612ab1565b6000815180845260208085019450808401835b838110156127b85781516001600160a01b031687529582019590820190600101612793565b509495945050505050565b6000815180845260208085019450808401835b838110156127b8578151875295820195908201906001016127d6565b60008251612804818460208701612a3e565b9190910192915050565b6001600160a01b0385811682528416602082015260806040820181905260009061283a90830185612780565b828103606084015261221681856127c3565b60408152600061285f6040830185612780565b828103602084015261287181856127c3565b95945050505050565b8481526080602082015260006128936080830186612780565b6001600160a01b03949094166040830152506060015292915050565b60208152600082518060208401526128ce816040850160208701612a3e565b601f01601f19169190910160400192915050565b602080825260139082015272546f6b656e206e6f7420737761707061626c6560681b604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b82815260406020820152600061213e6040830184612780565b85815284602082015260a06040820152600061299d60a0830186612780565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156129e3576129e3612a9b565b604052919050565b600067ffffffffffffffff821115612a0557612a05612a9b565b5060051b60200190565b60008219821115612a2257612a22612a85565b500190565b600082821015612a3957612a39612a85565b500390565b60005b83811015612a59578181015183820152602001612a41565b838111156108be5750506000910152565b6000600019821415612a7e57612a7e612a85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117c557600080fdfea26469706673582212205049298921bc98c707274355bc30070e8ecc3d64e22e4f8863e106e9963dfd3064736f6c63430008040033", + "numDeployments": 4, + "solcInputHash": "9768af37541e90e4200434e6de116099", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddresses\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"_tokenSymbolsForPaths\",\"type\":\"string[]\"},{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"name\":\"addPath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"addPoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromTokenAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPathsBySymbol\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Address\",\"type\":\"address\"}],\"name\":\"isERC20AddressEligible\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"isPoolAddressEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_isEligible\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"paths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"removePath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"removePoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tokenSymbolsForPaths\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, e.g., NCT\",\"sender\":\"The sender of the transaction\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}}},\"kind\":\"dev\",\"methods\":{\"addPath(string,address[])\":{\"params\":{\"_path\":\"The path of the path to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"addPoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to add\"}},\"autoOffsetExactInETH(address)\":{\"details\":\"This function is only available on Polygon, not on Celo.\",\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"params\":{\"_fromTokenAmount\":\"The amount of native tokens to swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of native tokens required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_paths\":\"An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.\",\"_poolAddresses\":\"A list of pool token addresses.\",\"_tokenSymbolsForPaths\":\"An array of symbols of the token the user want to retire carbon credits for\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"isERC20AddressEligible(address)\":{\"params\":{\"_erc20Address\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\"},\"returns\":{\"_path\":\"Returns the path of the token to be exchanged\"}},\"isPoolAddressEligible(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"_isEligible\":\"Returns a bool if the Pool token is eligible for offsetting\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"removePath(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the path to remove\"}},\"removePoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to remove\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"swapExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped native tokens .\"}},\"swapExactInToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT.\"}},\"kind\":\"user\",\"methods\":{\"addPath(string,address[])\":{\"notice\":\"Change or add eligible paths and their addresses.\"},\"addPoolToken(address)\":{\"notice\":\"Change or add pool token addresses.\"},\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC.\"},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"isERC20AddressEligible(address)\":{\"notice\":\"Checks if ERC20 Token is eligible for swapping.\"},\"isPoolAddressEligible(address)\":{\"notice\":\"Checks if Pool Address is eligible for offsetting.\"},\"removePath(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"removePoolToken(address)\":{\"notice\":\"Delete eligible pool token addresses stored in the contract.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped.\"},\"swapExactInToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\\n * swap on a DEX).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token e.g., NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n // Chain ID of Celo mainnet\\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token e.g., NCT.\\n *\\n * @param sender The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, e.g., NCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address sender,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Path doesn't yet exists.\\\");\\n\\n _;\\n }\\n\\n modifier nativeTokenChain() {\\n require(\\n block.chainid != CELO_MAINNET_CHAINID,\\n \\\"The function is not available on this network.\\\"\\n );\\n\\n _;\\n }\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _poolAddresses A list of pool token addresses.\\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\\n * to the provided token symbols.\\n */\\n constructor(\\n address[] memory _poolAddresses,\\n string[] memory _tokenSymbolsForPaths,\\n address[][] memory _paths,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n poolAddresses = _poolAddresses;\\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\\n paths = _paths;\\n\\n uint256 i = 0;\\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\\n while (i < eligibleSwapPathsBySymbolLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n // fallback payable and receive method to fix the situation where transfering dust native tokens\\n // in the native tokens to token swap fails\\n\\n receive() external payable {}\\n\\n fallback() external payable {}\\n\\n // ----------------------------------------\\n // Upgradable related functions\\n // ----------------------------------------\\n\\n function initialize() external virtual initializer {\\n __Ownable_init_unchained();\\n }\\n\\n // ----------------------------------------\\n // Public functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\\n * to determine how much native tokens e.g., MATIC must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to offset, e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\\n * can be used to calculate the expected amount of TCO2s that will be\\n * offset using `autoOffsetExactInToken()`.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToSwap\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(\\n _fromToken,\\n _poolToken,\\n _amountToSwap\\n );\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n *\\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\\n * the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\\n * to the user. This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(\\n address _poolToken,\\n uint256 _amountToOffset\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n * All provided native tokens is consumed for offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\\n * used to calculate the expected amount of TCO2s that will be offset\\n * using `autoOffsetExactInETH()`.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, e.g., NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\\n // calculate path & amounts\\n (\\n address[] memory path,\\n uint256[] memory expAmounts\\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(dexRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // calculate path & amounts\\n\\n address[] memory path = generatePath(_fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining native tokens that was not consumed by the swap is returned.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutETH(\\n address _poolToken,\\n uint256 _toAmount\\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\\n // create path & amounts\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided native tokens will be swapped.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped native tokens .\\n */\\n function swapExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // create path & amounts\\n uint256 fromAmount = msg.value;\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(\\n address _erc20Addr,\\n uint256 _amount\\n ) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(\\n address _fromToken,\\n uint256 _amount\\n )\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(\\n address[] memory _tco2s,\\n uint256[] memory _amounts\\n ) public {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n // ----------------------------------------\\n // Public view functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, e.g., NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n _fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n _fromToken,\\n _poolToken,\\n _fromAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, e.g., NCT.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of native tokens required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\\n *\\n * @param _fromTokenAmount The amount of native tokens to swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n address _poolToken,\\n uint256 _fromTokenAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n fromToken,\\n _poolToken,\\n _fromTokenAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Checks if Pool Address is eligible for offsetting.\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\\n */\\n function isPoolAddressEligible(\\n address _poolToken\\n ) public view returns (bool _isEligible) {\\n _isEligible = isRedeemable(_poolToken);\\n }\\n\\n /**\\n * @notice Checks if ERC20 Token is eligible for swapping.\\n * @param _erc20Address The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @return _path Returns the path of the token to be exchanged\\n */\\n function isERC20AddressEligible(\\n address _erc20Address\\n ) public view returns (address[] memory _path) {\\n _path = eligibleSwapPaths[_erc20Address];\\n }\\n\\n // ----------------------------------------\\n // Internal methods\\n // ----------------------------------------\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n /**\\n * @notice Show all pool token addresses that can be used to retired.\\n * @param _fromToken a list of token symbols that can be retired.\\n * @param _toToken a list of token symbols that can be retired.\\n */\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n function dexRouter() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(dexRouterAddress);\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < paths.length; i++) {\\n if (paths[i][0] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Cheks if Pool Token is eligible for Offsetting.\\n * @param _poolToken The addresses of the pool token to redeem\\n * @return _isEligible Returns if token can be redeemed\\n */\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible paths and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _path The path of the path to add\\n */\\n function addPath(\\n string memory _tokenSymbol,\\n address[] memory _path\\n ) public virtual onlyOwner {\\n eligibleSwapPaths[_path[0]] = _path;\\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\\n tokenSymbolsForPaths.push(_tokenSymbol);\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the path to remove\\n */\\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change or add pool token addresses.\\n * @param _poolToken The address of the pool token to add\\n */\\n function addPoolToken(address _poolToken) public virtual onlyOwner {\\n poolAddresses.push(_poolToken);\\n }\\n\\n /**\\n * @notice Delete eligible pool token addresses stored in the contract.\\n * @param _poolToken The address of the pool token to remove\\n */\\n function removePoolToken(address _poolToken) public virtual onlyOwner {\\n for (uint256 i; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _poolToken) {\\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\\n poolAddresses.pop();\\n break;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x00812c8474fe0303b130513d22e4a8cf4866cb16c3a5099203ef3fd769dc1f8a\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(address => address[]) public eligibleSwapPaths;\\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\\n\\n address public dexRouterAddress;\\n\\n address[] public poolAddresses;\\n string[] public tokenSymbolsForPaths;\\n address[][] public paths;\\n\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0xd505f00a17446ca29983779a8febff10114173db7f47ca4300d6a0bfce6b957a\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200416338038062004163833981016040819052620000349162000585565b606780546001600160a01b0319166001600160a01b038316179055835162000064906068906020870190620001fd565b5082516200007a90606990602086019062000267565b5081516200009090606a906020850190620002c7565b5082516000905b80821015620001f157838281518110620000c157634e487b7160e01b600052603260045260246000fd5b602002602001015160656000868581518110620000ee57634e487b7160e01b600052603260045260246000fd5b60200260200101516000815181106200011757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020908051906020019062000154929190620001fd565b508382815181106200017657634e487b7160e01b600052603260045260246000fd5b60200260200101516066868481518110620001a157634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620001b89190620006fc565b90815260200160405180910390209080519060200190620001db929190620001fd565b50620001e960018362000773565b915062000097565b5050505050506200081e565b82805482825590600052602060002090810192821562000255579160200282015b828111156200025557825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200021e565b506200026392915062000327565b5090565b828054828255906000526020600020908101928215620002b9579160200282015b82811115620002b95782518051620002a89184916020909101906200033e565b509160200191906001019062000288565b5062000263929150620003bb565b82805482825590600052602060002090810192821562000319579160200282015b8281111562000319578251805162000308918491602090910190620001fd565b5091602001919060010190620002e8565b5062000263929150620003dc565b5b8082111562000263576000815560010162000328565b8280546200034c90620007cb565b90600052602060002090601f01602090048101928262000370576000855562000255565b82601f106200038b57805160ff191683800117855562000255565b8280016001018555821562000255579182015b82811115620002555782518255916020019190600101906200039e565b8082111562000263576000620003d28282620003fd565b50600101620003bb565b8082111562000263576000620003f382826200043f565b50600101620003dc565b5080546200040b90620007cb565b6000825580601f106200041c575050565b601f0160209004906000526020600020908101906200043c919062000327565b50565b50805460008255906000526020600020908101906200043c919062000327565b80516001600160a01b03811681146200047757600080fd5b919050565b600082601f8301126200048d578081fd5b81516020620004a6620004a0836200074d565b6200071a565b80838252828201915082860187848660051b8901011115620004c6578586fd5b855b85811015620004ef57620004dc826200045f565b84529284019290840190600101620004c8565b5090979650505050505050565b600082601f8301126200050d578081fd5b8151602062000520620004a0836200074d565b80838252828201915082860187848660051b890101111562000540578586fd5b855b85811015620004ef5781516001600160401b0381111562000561578788fd5b620005718a87838c01016200047c565b855250928401929084019060010162000542565b600080600080608085870312156200059b578384fd5b84516001600160401b0380821115620005b2578586fd5b620005c0888389016200047c565b95506020870151915080821115620005d6578485fd5b818701915087601f830112620005ea578485fd5b8151620005fb620004a0826200074d565b80828252602082019150602085018b60208560051b88010111156200061e578889fd5b885b84811015620006b65781518681111562000638578a8bfd5b8701603f81018e1362000649578a8bfd5b60208101518781111562000661576200066162000808565b62000676601f8201601f19166020016200071a565b8181528f60408385010111156200068b578c8dfd5b6200069e82602083016040860162000798565b86525050602093840193919091019060010162000620565b505060408a01519097509350505080821115620006d1578384fd5b50620006e087828801620004fc565b925050620006f1606086016200045f565b905092959194509250565b600082516200071081846020870162000798565b9190910192915050565b604051601f8201601f191681016001600160401b038111828210171562000745576200074562000808565b604052919050565b60006001600160401b0382111562000769576200076962000808565b5060051b60200190565b600082198211156200079357634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620007b55781810151838201526020016200079b565b83811115620007c5576000848401525b50505050565b600181811c90821680620007e057607f821691505b602082108114156200080257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b613935806200082e6000396000f3fe6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "deployedBytecode": "0x6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", "devdoc": { "events": { "Redeemed(address,address,address[],uint256[])": { "params": { "amounts": "An array of the amounts of each TCO2 that were redeemed", - "poolToken": "The address of the Toucan pool token used in the redemption, for example, NCT or BCT", - "tco2s": "An array of the TCO2 addresses that were redeemed", - "who": "The sender of the transaction" + "poolToken": "The address of the Toucan pool token used in the redemption, e.g., NCT", + "sender": "The sender of the transaction", + "tco2s": "An array of the TCO2 addresses that were redeemed" } } }, "kind": "dev", "methods": { + "addPath(string,address[])": { + "params": { + "_path": "The path of the path to add", + "_tokenSymbol": "The symbol of the token to add" + } + }, + "addPoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to add" + } + }, "autoOffsetExactInETH(address)": { + "details": "This function is only available on Polygon, not on Celo.", "params": { - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", "tco2s": "An array of the TCO2 addresses that were redeemed" } }, - "autoOffsetExactInToken(address,uint256,address)": { + "autoOffsetExactInToken(address,address,uint256)": { "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", "params": { "_amountToSwap": "The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.", - "_fromToken": "The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT" + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -751,10 +918,10 @@ } }, "autoOffsetExactOutETH(address,uint256)": { - "details": "If the user sends much MATIC, the leftover amount will be sent back to the user.", + "details": "If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.", "params": { "_amountToOffset": "The amount of TCO2 to offset.", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -765,8 +932,8 @@ "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", "params": { "_amountToOffset": "The amount of TCO2 to offset", - "_depositedToken": "The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT" + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the Toucan pool token that the user wants to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -776,7 +943,7 @@ "autoOffsetPoolToken(address,uint256)": { "params": { "_amountToOffset": "The amount of TCO2 to offset.", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -787,7 +954,7 @@ "details": "Needs to be approved on the client side", "params": { "_amount": "Amount to redeem", - "_fromToken": "Could be the address of NCT or BCT" + "_fromToken": "Could be the address of NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -800,107 +967,118 @@ "_tco2s": "The addresses of the TCO2s to retire" } }, - "calculateExpectedPoolTokenForETH(uint256,address)": { + "calculateExpectedPoolTokenForETH(address,uint256)": { "params": { - "_fromMaticAmount": "The amount of MATIC to swap", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_fromTokenAmount": "The amount of native tokens to swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "The expected amount of Pool token that can be acquired" + "amountOut": "The expected amount of Pool token that can be acquired" } }, - "calculateExpectedPoolTokenForToken(address,uint256,address)": { + "calculateExpectedPoolTokenForToken(address,address,uint256)": { "params": { "_fromAmount": "The amount of ERC20 token to swap", "_fromToken": "The address of the ERC20 token used for the swap", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "The expected amount of Pool token that can be acquired" + "amountOut": "The expected amount of Pool token that can be acquired" } }, "calculateNeededETHAmount(address,uint256)": { "params": { - "_toAmount": "The desired amount of pool token to receive", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" }, "returns": { - "_0": "amounts The amount of MATIC required in order to swap for the specified amount of the pool token" + "amountIn": "The amount of native tokens required in order to swap for the specified amount of the pool token" } }, "calculateNeededTokenAmount(address,address,uint256)": { "params": { "_fromToken": "The address of the ERC20 token used for the swap", - "_toAmount": "The desired amount of pool token to receive", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" }, "returns": { - "_0": "amountsIn The amount of the ERC20 token required in order to swap for the specified amount of the pool token" + "amountIn": "The amount of the ERC20 token required in order to swap for the specified amount of the pool token" } }, "constructor": { "details": "See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.", "params": { - "_eligibleTokenAddresses": "A list of token addresses corresponding to the provided token symbols.", - "_eligibleTokenSymbols": "A list of token symbols." + "_paths": "An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.", + "_poolAddresses": "A list of pool token addresses.", + "_tokenSymbolsForPaths": "An array of symbols of the token the user want to retire carbon credits for" } }, - "deleteEligibleTokenAddress(string)": { + "deposit(address,uint256)": { + "details": "Needs to be approved" + }, + "isERC20AddressEligible(address)": { "params": { - "_tokenSymbol": "The symbol of the token to remove" + "_erc20Address": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)" + }, + "returns": { + "_path": "Returns the path of the token to be exchanged" } }, - "deposit(address,uint256)": { - "details": "Needs to be approved" + "isPoolAddressEligible(address)": { + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "_isEligible": "Returns a bool if the Pool token is eligible for offsetting" + } }, "owner()": { "details": "Returns the address of the current owner." }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "setEligibleTokenAddress(string,address)": { + "removePath(string)": { "params": { - "_address": "The address of the token to add", - "_tokenSymbol": "The symbol of the token to add" + "_tokenSymbol": "The symbol of the path to remove" } }, - "setToucanContractRegistry(address)": { + "removePoolToken(address)": { "params": { - "_address": "The address of the Toucan contract registry to use" + "_poolToken": "The address of the pool token to remove" } }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, "swapExactInETH(address)": { "params": { - "_toToken": "Token to swap for (will be held within contract)" + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "Resulting amount of Toucan pool token that got acquired for the swapped MATIC." + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped native tokens ." } }, - "swapExactInToken(address,uint256,address)": { + "swapExactInToken(address,address,uint256)": { "details": "Needs to be approved on the client side.", "params": { "_fromAmount": "The amount of ERC20 token to swap", - "_fromToken": "The ERC20 token to deposit and swap", - "_toToken": "The Toucan token to swap for (will be held within contract)" + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." } }, "swapExactOutETH(address,uint256)": { "params": { - "_toAmount": "Amount of NCT / BCT wanted", - "_toToken": "Token to swap for (will be held within contract)" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" } }, "swapExactOutToken(address,address,uint256)": { "details": "Needs to be approved on the client side", "params": { - "_fromToken": "The ERC20 oken to deposit and swap", - "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)", - "_toToken": "The token to swap for (will be held within contract)" + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" } }, "transferOwnership(address)": { @@ -913,25 +1091,31 @@ "userdoc": { "events": { "Redeemed(address,address,address[],uint256[])": { - "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token such as BCT or NCT." + "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT." } }, "kind": "user", "methods": { + "addPath(string,address[])": { + "notice": "Change or add eligible paths and their addresses." + }, + "addPoolToken(address)": { + "notice": "Change or add pool token addresses." + }, "autoOffsetExactInETH(address)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. All provided MATIC is consumed for offsetting. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." }, - "autoOffsetExactInToken(address,uint256,address)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). All provided token is consumed for offsetting. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + "autoOffsetExactInToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." }, "autoOffsetExactOutETH(address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. Use `calculateNeededETHAmount()` first in order to find out how much MATIC is required to retire the specified quantity of TCO2. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." }, "autoOffsetExactOutToken(address,address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in order to find out how much of the ERC20 token is required to retire the specified quantity of TCO2. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." }, "autoOffsetPoolToken(address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, for example, BCT or NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." }, "autoRedeem(address,uint256)": { "notice": "Redeems the specified amount of NCT / BCT for TCO2." @@ -939,41 +1123,44 @@ "autoRetire(address[],uint256[])": { "notice": "Retire the specified TCO2 tokens." }, - "calculateExpectedPoolTokenForETH(uint256,address)": { - "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of MATIC." + "calculateExpectedPoolTokenForETH(address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC." }, - "calculateExpectedPoolTokenForToken(address,uint256,address)": { + "calculateExpectedPoolTokenForToken(address,address,uint256)": { "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token." }, "calculateNeededETHAmount(address,uint256)": { - "notice": "Return how much MATIC is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT." + "notice": "Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT." }, "calculateNeededTokenAmount(address,address,uint256)": { - "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT." + "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT." }, "constructor": { "notice": "Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract." }, - "deleteEligibleTokenAddress(string)": { - "notice": "Delete eligible tokens stored in the contract." - }, "deposit(address,uint256)": { "notice": "Allow users to deposit BCT / NCT." }, - "setEligibleTokenAddress(string,address)": { - "notice": "Change or add eligible tokens and their addresses." + "isERC20AddressEligible(address)": { + "notice": "Checks if ERC20 Token is eligible for swapping." + }, + "isPoolAddressEligible(address)": { + "notice": "Checks if Pool Address is eligible for offsetting." + }, + "removePath(string)": { + "notice": "Delete eligible tokens stored in the contract." }, - "setToucanContractRegistry(address)": { - "notice": "Change the TCO2 contracts registry." + "removePoolToken(address)": { + "notice": "Delete eligible pool token addresses stored in the contract." }, "swapExactInETH(address)": { - "notice": "Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided MATIC will be swapped." + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped." }, - "swapExactInToken(address,uint256,address)": { + "swapExactInToken(address,address,uint256)": { "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped." }, "swapExactOutETH(address,uint256)": { - "notice": "Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining MATIC that was not consumed by the swap is returned." + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned." }, "swapExactOutToken(address,address,uint256)": { "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap" @@ -982,13 +1169,13 @@ "notice": "Allow users to withdraw tokens they have deposited." } }, - "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token swap). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token such as BCT or NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using MATIC, specifying the exact amount of TCO2s to retire, - `autoOffsetExactInETH()` if the user would like to perform a retirement using MATIC, swapping all sent MATIC into TCO2s, - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", + "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", "version": 1 }, "storageLayout": { "storage": [ { - "astId": 527, + "astId": 138, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "_initialized", "offset": 0, @@ -996,7 +1183,7 @@ "type": "t_uint8" }, { - "astId": 530, + "astId": 141, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "_initializing", "offset": 1, @@ -1004,7 +1191,7 @@ "type": "t_bool" }, { - "astId": 1344, + "astId": 703, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "__gap", "offset": 0, @@ -1028,35 +1215,59 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 5022, + "astId": 3502, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "eligibleTokenAddresses", + "label": "eligibleSwapPaths", "offset": 0, "slot": "101", - "type": "t_mapping(t_string_memory_ptr,t_address)" + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" }, { - "astId": 5025, + "astId": 3507, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "contractRegistryAddress", + "label": "eligibleSwapPathsBySymbol", "offset": 0, "slot": "102", - "type": "t_address" + "type": "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)" }, { - "astId": 5028, + "astId": 3509, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "sushiRouterAddress", + "label": "dexRouterAddress", "offset": 0, "slot": "103", "type": "t_address" }, { - "astId": 5034, + "astId": 3512, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "balances", + "label": "poolAddresses", "offset": 0, "slot": "104", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 3515, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "tokenSymbolsForPaths", + "offset": 0, + "slot": "105", + "type": "t_array(t_string_storage)dyn_storage" + }, + { + "astId": 3519, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "paths", + "offset": 0, + "slot": "106", + "type": "t_array(t_array(t_address)dyn_storage)dyn_storage" + }, + { + "astId": 3525, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "balances", + "offset": 0, + "slot": "107", "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" } ], @@ -1066,6 +1277,24 @@ "label": "address", "numberOfBytes": "20" }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_array(t_address)dyn_storage)dyn_storage": { + "base": "t_array(t_address)dyn_storage", + "encoding": "dynamic_array", + "label": "address[][]", + "numberOfBytes": "32" + }, + "t_array(t_string_storage)dyn_storage": { + "base": "t_string_storage", + "encoding": "dynamic_array", + "label": "string[]", + "numberOfBytes": "32" + }, "t_array(t_uint256)49_storage": { "base": "t_uint256", "encoding": "inplace", @@ -1083,6 +1312,13 @@ "label": "bool", "numberOfBytes": "1" }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, "t_mapping(t_address,t_mapping(t_address,t_uint256))": { "encoding": "mapping", "key": "t_address", @@ -1097,18 +1333,23 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_mapping(t_string_memory_ptr,t_address)": { + "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)": { "encoding": "mapping", "key": "t_string_memory_ptr", - "label": "mapping(string => address)", + "label": "mapping(string => address[])", "numberOfBytes": "32", - "value": "t_address" + "value": "t_array(t_address)dyn_storage" }, "t_string_memory_ptr": { "encoding": "bytes", "label": "string", "numberOfBytes": "32" }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, "t_uint256": { "encoding": "inplace", "label": "uint256", diff --git a/deployments/mumbai/Swapper.json b/deployments/mumbai/Swapper.json new file mode 100644 index 0000000..eafd18b --- /dev/null +++ b/deployments/mumbai/Swapper.json @@ -0,0 +1,238 @@ +{ + "address": "0x68DF99A11BD292cB91d3Fb07272062eF339d6dc1", + "abi": [ + { + "inputs": [ + { + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_swapToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "calculateNeededETHAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "swapToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x189df93578c35486a28cb220d6d3b429ea77c65c2af2cfb50e2911f6fbc2e87f", + "receipt": { + "to": null, + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0x68DF99A11BD292cB91d3Fb07272062eF339d6dc1", + "transactionIndex": 2, + "gasUsed": "1095374", + "logsBloom": "0x00000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000800000000000000000000100000000000000000000000000000000000000000000000000000000000080000020000000000000000000000000000000000000000000000000000000000000000000000000200000000000000020000000000000000001000000000000000000000000004000000000000000000001000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000100000", + "blockHash": "0x0d5348789c87a015ed193a8fa05309ae5ef764cf472034e61961f8d0b672d717", + "transactionHash": "0x189df93578c35486a28cb220d6d3b429ea77c65c2af2cfb50e2911f6fbc2e87f", + "logs": [ + { + "transactionIndex": 2, + "blockNumber": 40040205, + "transactionHash": "0x189df93578c35486a28cb220d6d3b429ea77c65c2af2cfb50e2911f6fbc2e87f", + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x000000000000000000000000101b4c436df747b24d17ce43146da52fa6006c36", + "0x000000000000000000000000c26880a0af2ea0c7e8130e6ec47af756465452e8" + ], + "data": "0x0000000000000000000000000000000000000000000000000009ba97956a5e00000000000000000000000000000000000000000000000000143baad6c87f9ded0000000000000000000000000000000000000000000021bf096e369708e478a60000000000000000000000000000000000000000000000001431f03f33153fed0000000000000000000000000000000000000000000021bf0977f12e9e4ed6a6", + "logIndex": 12, + "blockHash": "0x0d5348789c87a015ed193a8fa05309ae5ef764cf472034e61961f8d0b672d717" + } + ], + "blockNumber": 40040205, + "cumulativeGasUsed": "3521705", + "status": 1, + "byzantium": true + }, + "args": [ + [ + [ + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ], + [ + "0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ], + [ + "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", + "0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747" + ] + ], + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" + ], + "numDeployments": 1, + "solcInputHash": "10fe5cc2e77ff4188aab80798438e159", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_swapToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/Swapper.sol\":\"Swapper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/test/Swapper.sol\":{\"content\":\"//SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\n\\ncontract Swapper {\\n using SafeERC20 for IERC20;\\n\\n mapping(address => address[]) public eligibleSwapPaths;\\n address public swapToken;\\n address public dexRouterAddress;\\n\\n constructor(\\n address[][] memory _paths,\\n address _swapToken,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n swapToken = _swapToken;\\n uint256 i = 0;\\n uint256 eligibleSwapPathsLen = _paths.length;\\n while (i < eligibleSwapPathsLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n function calculateNeededETHAmount(\\n address _toToken,\\n uint256 _amount\\n ) public view returns (uint256) {\\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\\n\\n address[] memory path = generatePath(swapToken, _toToken);\\n uint256 len = path.length;\\n\\n uint256[] memory amounts = dexRouter.getAmountsIn(_amount, path);\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_amount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n return amounts[0];\\n }\\n\\n function swap(address _toToken, uint256 _amount) public payable {\\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\\n\\n address[] memory path = generatePath(swapToken, _toToken);\\n\\n uint256[] memory amounts = dexRouter.swapETHForExactTokens{\\n value: msg.value\\n }(_amount, path, address(this), block.timestamp);\\n\\n IERC20(_toToken).transfer(msg.sender, _amount);\\n\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus ETH back to user.\\\");\\n }\\n }\\n\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1 || eligibleSwapPaths[_fromToken][1] == _toToken) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2 || eligibleSwapPaths[_fromToken][2] == _toToken) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3 || eligibleSwapPaths[_fromToken][3] == _toToken) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n fallback() external payable {}\\n\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0x1c94d4fbe790309896da85bc2ecf6b8758d2c3f02d3ab78d156b24ca047e0987\",\"license\":\"Unlicense\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001255380380620012558339810160408190526200003491620001e5565b600280546001600160a01b038084166001600160a01b031992831617909255600180549285169290911691909117905582516000905b808210156200013c578482815181106200009457634e487b7160e01b600052603260045260246000fd5b6020026020010151600080878581518110620000c057634e487b7160e01b600052603260045260246000fd5b6020026020010151600081518110620000e957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002090805190602001906200012692919062000147565b50620001346001836200039b565b91506200006a565b5050505050620003d6565b8280548282559060005260206000209081019282156200019f579160200282015b828111156200019f57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000168565b50620001ad929150620001b1565b5090565b5b80821115620001ad5760008155600101620001b2565b80516001600160a01b0381168114620001e057600080fd5b919050565b600080600060608486031215620001fa578283fd5b83516001600160401b0381111562000210578384fd5b8401601f8101861362000221578384fd5b805162000238620002328262000375565b62000342565b80828252602082019150602084018960208560051b87010111156200025b578788fd5b875b84811015620003125781516001600160401b038111156200027c57898afd5b8b603f82890101126200028d57898afd5b60208188010151620002a3620002328262000375565b808282526020820191506040848b01018f60408560051b878e0101011115620002ca578d8efd5b8d94505b83851015620002f857620002e281620001c8565b83526001949094019360209283019201620002ce565b50875250506020948501949290920191506001016200025d565b5050809650505050506200032960208501620001c8565b91506200033960408501620001c8565b90509250925092565b604051601f8201601f191681016001600160401b03811182821017156200036d576200036d620003c0565b604052919050565b60006001600160401b03821115620003915762000391620003c0565b5060051b60200190565b60008219821115620003bb57634e487b7160e01b81526011600452602481fd5b500190565b634e487b7160e01b600052604160045260246000fd5b610e6f80620003e66000396000f3fe60806040526004361061004b5760003560e01c80631109ec99146100545780631357b11314610087578063d004f0f7146100bf578063dc73e49c146100d2578063e7f67fb1146100f257005b3661005257005b005b34801561006057600080fd5b5061007461006f366004610c11565b610112565b6040519081526020015b60405180910390f35b34801561009357600080fd5b506100a76100a2366004610c11565b6102b6565b6040516001600160a01b03909116815260200161007e565b6100526100cd366004610c11565b6102ee565b3480156100de57600080fd5b506001546100a7906001600160a01b031681565b3480156100fe57600080fd5b506002546100a7906001600160a01b031681565b6002546001546000916001600160a01b03908116918391610134911686610554565b80516040516307c0329d60e21b8152919250906000906001600160a01b03851690631f00ca749061016b9089908790600401610daa565b60006040518083038186803b15801561018357600080fd5b505afa158015610197573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101bf9190810190610c47565b9050805182146102075760405162461bcd60e51b815260206004820152600e60248201526d105c9c985e5cc81d5b995c5d585b60921b60448201526064015b60405180910390fd5b80610213600184610e00565b8151811061023157634e487b7160e01b600052603260045260246000fd5b602002602001015186146102805760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b60448201526064016101fe565b806000815181106102a157634e487b7160e01b600052603260045260246000fd5b60200260200101519450505050505b92915050565b600060205281600052604060002081815481106102d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546001546001600160a01b039182169160009161030e911685610554565b90506000826001600160a01b031663fb3bdb4134868530426040518663ffffffff1660e01b81526004016103459493929190610dcb565b6000604051808303818588803b15801561035e57600080fd5b505af1158015610372573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261039b9190810190610c47565b60405163a9059cbb60e01b8152336004820152602481018690529091506001600160a01b0386169063a9059cbb90604401602060405180830381600087803b1580156103e657600080fd5b505af11580156103fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e9190610d07565b508060008151811061044057634e487b7160e01b600052603260045260246000fd5b602002602001015134111561054d5760008160008151811061047257634e487b7160e01b600052603260045260246000fd5b6020026020010151346104859190610e00565b6040805160008082526020820192839052929350339184916104a691610d71565b60006040518083038185875af1925050503d80600081146104e3576040519150601f19603f3d011682016040523d82523d6000602084013e6104e8565b606091505b505090508061054a5760405162461bcd60e51b815260206004820152602860248201527f4661696c656420746f2073656e6420737572706c757320455448206261636b206044820152673a37903ab9b2b91760c11b60648201526084016101fe565b50505b5050505050565b6001600160a01b03821660009081526020819052604090205460609060018114806105cf57506001600160a01b03848116600090815260208190526040902080549185169160019081106105b857634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b1561067e576040805160028082526060820183529091602083019080368337019050509150838260008151811061061657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061065857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050506102b0565b80600214806106dd57506001600160a01b03848116600090815260208190526040902080549185169160029081106106c657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156107f157604080516003808252608082019092529060208201606080368337019050509150838260008151811061072557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600190811061077057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106107af57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061065857634e487b7160e01b600052603260045260246000fd5b806003148061085057506001600160a01b038481166000908152602081905260409020805491851691600390811061083957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156109ee57604080516003808252608082019092529060208201606080368337019050509150838260008151811061089857634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081529081905260409020805460019081106108e357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061092257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600290811061096d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106109ac57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061065857634e487b7160e01b600052603260045260246000fd5b60408051600480825260a0820190925290602082016080803683370190505091508382600081518110610a3157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546001908110610a7c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600181518110610abb57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546002908110610b0657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600281518110610b4557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546003908110610b9057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600381518110610bcf57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061065857634e487b7160e01b600052603260045260246000fd5b60008060408385031215610c23578182fd5b82356001600160a01b0381168114610c39578283fd5b946020939093013593505050565b60006020808385031215610c59578182fd5b825167ffffffffffffffff80821115610c70578384fd5b818501915085601f830112610c83578384fd5b815181811115610c9557610c95610e23565b8060051b604051601f19603f83011681018181108582111715610cba57610cba610e23565b604052828152858101935084860182860187018a1015610cd8578788fd5b8795505b83861015610cfa578051855260019590950194938601938601610cdc565b5098975050505050505050565b600060208284031215610d18578081fd5b81518015158114610d27578182fd5b9392505050565b6000815180845260208085019450808401835b83811015610d665781516001600160a01b031687529582019590820190600101610d41565b509495945050505050565b60008251815b81811015610d915760208186018101518583015201610d77565b81811115610d9f5782828501525b509190910192915050565b828152604060208201526000610dc36040830184610d2e565b949350505050565b848152608060208201526000610de46080830186610d2e565b6001600160a01b03949094166040830152506060015292915050565b600082821015610e1e57634e487b7160e01b81526011600452602481fd5b500390565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220fc2f138f7a83ba4ce4fd2105384e2316195b1f1ac4e2d922f02f23d19970aa9c64736f6c63430008040033", + "deployedBytecode": "0x60806040526004361061004b5760003560e01c80631109ec99146100545780631357b11314610087578063d004f0f7146100bf578063dc73e49c146100d2578063e7f67fb1146100f257005b3661005257005b005b34801561006057600080fd5b5061007461006f366004610c11565b610112565b6040519081526020015b60405180910390f35b34801561009357600080fd5b506100a76100a2366004610c11565b6102b6565b6040516001600160a01b03909116815260200161007e565b6100526100cd366004610c11565b6102ee565b3480156100de57600080fd5b506001546100a7906001600160a01b031681565b3480156100fe57600080fd5b506002546100a7906001600160a01b031681565b6002546001546000916001600160a01b03908116918391610134911686610554565b80516040516307c0329d60e21b8152919250906000906001600160a01b03851690631f00ca749061016b9089908790600401610daa565b60006040518083038186803b15801561018357600080fd5b505afa158015610197573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101bf9190810190610c47565b9050805182146102075760405162461bcd60e51b815260206004820152600e60248201526d105c9c985e5cc81d5b995c5d585b60921b60448201526064015b60405180910390fd5b80610213600184610e00565b8151811061023157634e487b7160e01b600052603260045260246000fd5b602002602001015186146102805760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b60448201526064016101fe565b806000815181106102a157634e487b7160e01b600052603260045260246000fd5b60200260200101519450505050505b92915050565b600060205281600052604060002081815481106102d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546001546001600160a01b039182169160009161030e911685610554565b90506000826001600160a01b031663fb3bdb4134868530426040518663ffffffff1660e01b81526004016103459493929190610dcb565b6000604051808303818588803b15801561035e57600080fd5b505af1158015610372573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261039b9190810190610c47565b60405163a9059cbb60e01b8152336004820152602481018690529091506001600160a01b0386169063a9059cbb90604401602060405180830381600087803b1580156103e657600080fd5b505af11580156103fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e9190610d07565b508060008151811061044057634e487b7160e01b600052603260045260246000fd5b602002602001015134111561054d5760008160008151811061047257634e487b7160e01b600052603260045260246000fd5b6020026020010151346104859190610e00565b6040805160008082526020820192839052929350339184916104a691610d71565b60006040518083038185875af1925050503d80600081146104e3576040519150601f19603f3d011682016040523d82523d6000602084013e6104e8565b606091505b505090508061054a5760405162461bcd60e51b815260206004820152602860248201527f4661696c656420746f2073656e6420737572706c757320455448206261636b206044820152673a37903ab9b2b91760c11b60648201526084016101fe565b50505b5050505050565b6001600160a01b03821660009081526020819052604090205460609060018114806105cf57506001600160a01b03848116600090815260208190526040902080549185169160019081106105b857634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b1561067e576040805160028082526060820183529091602083019080368337019050509150838260008151811061061657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061065857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050506102b0565b80600214806106dd57506001600160a01b03848116600090815260208190526040902080549185169160029081106106c657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156107f157604080516003808252608082019092529060208201606080368337019050509150838260008151811061072557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600190811061077057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106107af57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061065857634e487b7160e01b600052603260045260246000fd5b806003148061085057506001600160a01b038481166000908152602081905260409020805491851691600390811061083957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156109ee57604080516003808252608082019092529060208201606080368337019050509150838260008151811061089857634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081529081905260409020805460019081106108e357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061092257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600290811061096d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106109ac57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061065857634e487b7160e01b600052603260045260246000fd5b60408051600480825260a0820190925290602082016080803683370190505091508382600081518110610a3157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546001908110610a7c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600181518110610abb57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546002908110610b0657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600281518110610b4557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546003908110610b9057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600381518110610bcf57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061065857634e487b7160e01b600052603260045260246000fd5b60008060408385031215610c23578182fd5b82356001600160a01b0381168114610c39578283fd5b946020939093013593505050565b60006020808385031215610c59578182fd5b825167ffffffffffffffff80821115610c70578384fd5b818501915085601f830112610c83578384fd5b815181811115610c9557610c95610e23565b8060051b604051601f19603f83011681018181108582111715610cba57610cba610e23565b604052828152858101935084860182860187018a1015610cd8578788fd5b8795505b83861015610cfa578051855260019590950194938601938601610cdc565b5098975050505050505050565b600060208284031215610d18578081fd5b81518015158114610d27578182fd5b9392505050565b6000815180845260208085019450808401835b83811015610d665781516001600160a01b031687529582019590820190600101610d41565b509495945050505050565b60008251815b81811015610d915760208186018101518583015201610d77565b81811115610d9f5782828501525b509190910192915050565b828152604060208201526000610dc36040830184610d2e565b949350505050565b848152608060208201526000610de46080830186610d2e565b6001600160a01b03949094166040830152506060015292915050565b600082821015610e1e57634e487b7160e01b81526011600452602481fd5b500390565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220fc2f138f7a83ba4ce4fd2105384e2316195b1f1ac4e2d922f02f23d19970aa9c64736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1133, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "eligibleSwapPaths", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" + }, + { + "astId": 1135, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "swapToken", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 1137, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "dexRouterAddress", + "offset": 0, + "slot": "2", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + } + } + } +} \ No newline at end of file diff --git a/deployments/mumbai/solcInputs/10fe5cc2e77ff4188aab80798438e159.json b/deployments/mumbai/solcInputs/10fe5cc2e77ff4188aab80798438e159.json new file mode 100644 index 0000000..81a063a --- /dev/null +++ b/deployments/mumbai/solcInputs/10fe5cc2e77ff4188aab80798438e159.json @@ -0,0 +1,53 @@ +{ + "language": "Solidity", + "sources": { + "@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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/test/Swapper.sol": { + "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\n\ncontract Swapper {\n using SafeERC20 for IERC20;\n\n mapping(address => address[]) public eligibleSwapPaths;\n address public swapToken;\n address public dexRouterAddress;\n\n constructor(\n address[][] memory _paths,\n address _swapToken,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n swapToken = _swapToken;\n uint256 i = 0;\n uint256 eligibleSwapPathsLen = _paths.length;\n while (i < eligibleSwapPathsLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n i += 1;\n }\n }\n\n function calculateNeededETHAmount(\n address _toToken,\n uint256 _amount\n ) public view returns (uint256) {\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\n\n address[] memory path = generatePath(swapToken, _toToken);\n uint256 len = path.length;\n\n uint256[] memory amounts = dexRouter.getAmountsIn(_amount, path);\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_amount == amounts[len - 1], \"Output amount mismatch\");\n return amounts[0];\n }\n\n function swap(address _toToken, uint256 _amount) public payable {\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\n\n address[] memory path = generatePath(swapToken, _toToken);\n\n uint256[] memory amounts = dexRouter.swapETHForExactTokens{\n value: msg.value\n }(_amount, path, address(this), block.timestamp);\n\n IERC20(_toToken).transfer(msg.sender, _amount);\n\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus ETH back to user.\");\n }\n }\n\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1 || eligibleSwapPaths[_fromToken][1] == _toToken) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2 || eligibleSwapPaths[_fromToken][2] == _toToken) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3 || eligibleSwapPaths[_fromToken][3] == _toToken) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n fallback() external payable {}\n\n receive() external payable {}\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/mumbai/solcInputs/84d45862bdebcae922b40dea008570ca.json b/deployments/mumbai/solcInputs/84d45862bdebcae922b40dea008570ca.json deleted file mode 100644 index 45b686d..0000000 --- a/deployments/mumbai/solcInputs/84d45862bdebcae922b40dea008570ca.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/interfaces/draft-IERC1822Upgradeable.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 IERC1822ProxiableUpgradeable {\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-upgradeable/proxy/beacon/IBeaconUpgradeable.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 IBeaconUpgradeable {\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-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.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/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.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 ERC1967UpgradeUpgradeable is Initializable {\n function __ERC1967Upgrade_init() internal onlyInitializing {\n }\n\n function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n }\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 StorageSlotUpgradeable.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(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.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 _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 (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822ProxiableUpgradeable(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 StorageSlotUpgradeable.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 StorageSlotUpgradeable.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 StorageSlotUpgradeable.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(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.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 _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\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(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\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/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n }\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\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. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeTo(address newImplementation) external virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) 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[50] private __gap;\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/token/ERC721/IERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts-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/utils/introspection/IERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 MathUpgradeable {\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. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.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 StorageSlotUpgradeable {\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-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@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/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { - "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" - }, - "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { - "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" - }, - "contracts/interfaces/IRetirementCertificates.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\n\nimport \"./IToucanContractRegistry.sol\";\n\ninterface RetirementCertificates is IERC721Upgradeable {\n /// @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n function tokenURI(uint256 tokenId) external returns (string memory);\n\n /// @notice Update retirementMessage, beneficiary, and beneficiaryString of a NFT\n /// within 24h of creation. Empty values are ignored, ie., will not overwrite the\n /// existing stored values in the NFT.\n /// @param tokenId The id of the NFT to update\n /// @param beneficiary The new beneficiary to set in the NFT\n /// @param beneficiaryString The new beneficiaryString to set in the NFT\n /// @param retirementMessage The new retirementMessage to set in the NFT\n /// @dev The function can only be called by a the NFT owner\n function updateCertificate(\n uint256 tokenId,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage\n ) external;\n}\n" - }, - "contracts/interfaces/IToucanCarbonOffsets.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" - }, - "contracts/interfaces/IToucanContractRegistry.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" - }, - "contracts/interfaces/IToucanPoolToken.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" - }, - "contracts/OffsetHelper.sol": { - "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token\n * swap).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token such as BCT or NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using MATIC, specifying the exact amount of TCO2s to retire,\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using MATIC, swapping all sent MATIC into TCO2s,\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _eligibleTokenSymbols A list of token symbols.\n * @param _eligibleTokenAddresses A list of token addresses corresponding\n * to the provided token symbols.\n */\n constructor(\n string[] memory _eligibleTokenSymbols,\n address[] memory _eligibleTokenAddresses\n ) {\n uint256 i = 0;\n uint256 eligibleTokenSymbolsLen = _eligibleTokenSymbols.length;\n while (i < eligibleTokenSymbolsLen) {\n eligibleTokenAddresses[\n _eligibleTokenSymbols[i]\n ] = _eligibleTokenAddresses[i];\n i += 1;\n }\n }\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token such as BCT or NCT.\n *\n * @param who The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, for example, NCT or BCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address who,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Token not swappable\");\n\n _;\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in\n * order to find out how much of the ERC20 token is required to retire the\n * specified quantity of TCO2.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _depositedToken The address of the ERC20 token that the user sends\n * (must be one of USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _depositedToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_depositedToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (must be one of USDC, WETH, WMATIC)\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n uint256 _amountToSwap,\n address _poolToken\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(_fromToken, _amountToSwap, _poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending MATIC.\n * Use `calculateNeededETHAmount()` first in order to find out how much\n * MATIC is required to retire the specified quantity of TCO2.\n *\n * This function:\n * 1. Swaps the Matic sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends much MATIC, the leftover amount will be sent back\n * to the user.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(address _poolToken, uint256 _amountToOffset)\n public\n payable\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap MATIC for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending MATIC.\n * All provided MATIC is consumed for offsetting.\n *\n * This function:\n * 1. Swaps the Matic sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(address _poolToken)\n public\n payable\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap MATIC for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, for example, BCT or NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Checks whether an address can be used by the contract.\n * @param _erc20Address address of the ERC20 token to be checked\n * @return True if the address can be used by the contract\n */\n function isEligible(address _erc20Address) private view returns (bool) {\n bool isToucanContract = IToucanContractRegistry(contractRegistryAddress)\n .checkERC20(_erc20Address);\n if (isToucanContract) return true;\n if (_erc20Address == eligibleTokenAddresses[\"BCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"NCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"USDC\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WETH\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WMATIC\"]) return true;\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n if (_erc20Address == eligibleTokenAddresses[\"USDC\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WETH\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WMATIC\"]) return true;\n return false;\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n if (_erc20Address == eligibleTokenAddresses[\"BCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"NCT\"]) return true;\n return false;\n }\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, BCT or NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountsIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _toToken,\n uint256 _toAmount\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n (, uint256[] memory amounts) =\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\n return amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _fromAmount The amount of ERC20 token to swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @return The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n (, uint256[] memory amounts) =\n calculateExactInSwap(_fromToken, _fromAmount, _toToken);\n return amounts[amounts.length - 1];\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The ERC20 oken to deposit and swap\n * @param _toToken The token to swap for (will be held within contract)\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _toToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) {\n // calculate path & amounts\n (address[] memory path, uint256[] memory expAmounts) =\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(sushiRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = routerSushi().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(sushiRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_toToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The ERC20 token to deposit and swap\n * @param _fromAmount The amount of ERC20 token to swap\n * @param _toToken The Toucan token to swap for (will be held within contract)\n * @return Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n // calculate path & amounts\n address[] memory path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(sushiRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = routerSushi().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n uint256 amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_toToken] += amountOut;\n\n return amountOut;\n }\n\n // apparently I need a fallback and a receive method to fix the situation where transfering dust MATIC\n // in the MATIC to token swap fails\n fallback() external payable {}\n\n receive() external payable {}\n\n /**\n * @notice Return how much MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, for example, BCT or NCT.\n *\n * @param _toToken The address of the pool token to swap for, for\n * example, NCT or BCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amounts The amount of MATIC required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(address _toToken, uint256 _toAmount)\n public\n view\n onlyRedeemable(_toToken)\n returns (uint256)\n {\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n (, uint256[] memory amounts) =\n calculateExactOutSwap(fromToken, _toToken, _toAmount);\n return amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of MATIC.\n *\n * @param _fromMaticAmount The amount of MATIC to swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @return The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n uint256 _fromMaticAmount,\n address _toToken\n ) public view onlyRedeemable(_toToken) returns (uint256) {\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n (, uint256[] memory amounts) =\n calculateExactInSwap(fromToken, _fromMaticAmount, _toToken);\n return amounts[amounts.length - 1];\n }\n\n /**\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining MATIC that was not consumed by the swap is returned.\n * @param _toToken Token to swap for (will be held within contract)\n * @param _toAmount Amount of NCT / BCT wanted\n */\n function swapExactOutETH(address _toToken, uint256 _toAmount) public payable onlyRedeemable(_toToken) {\n // calculate path & amounts\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n address[] memory path = generatePath(fromToken, _toToken);\n\n // swap\n uint256[] memory amounts = routerSushi().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_toToken] += _toAmount;\n }\n\n /**\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided MATIC will be swapped.\n * @param _toToken Token to swap for (will be held within contract)\n * @return Resulting amount of Toucan pool token that got acquired for the\n * swapped MATIC.\n */\n function swapExactInETH(address _toToken) public payable onlyRedeemable(_toToken) returns (uint256) {\n // calculate path & amounts\n uint256 fromAmount = msg.value;\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n address[] memory path = generatePath(fromToken, _toToken);\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = routerSushi().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n uint256 amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_toToken] += amountOut;\n\n return amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(address _erc20Addr, uint256 _amount) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT or BCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(address _fromToken, uint256 _amount)\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT or BCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(address[] memory _tco2s, uint256[] memory _amounts)\n public\n {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n function calculateExactOutSwap(\n address _fromToken,\n address _toToken,\n uint256 _toAmount)\n internal view\n returns (address[] memory path, uint256[] memory amounts)\n {\n path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n amounts = routerSushi().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken)\n internal view\n returns (address[] memory path, uint256[] memory amounts)\n {\n path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n amounts = routerSushi().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n function generatePath(address _fromToken, address _toToken)\n internal\n view\n returns (address[] memory)\n {\n if (_fromToken == eligibleTokenAddresses[\"USDC\"]) {\n address[] memory path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleTokenAddresses[\"USDC\"];\n path[2] = _toToken;\n return path;\n }\n }\n\n function routerSushi() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(sushiRouterAddress);\n }\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible tokens and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _address The address of the token to add\n */\n function setEligibleTokenAddress(\n string memory _tokenSymbol,\n address _address\n ) public virtual onlyOwner {\n eligibleTokenAddresses[_tokenSymbol] = _address;\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the token to remove\n */\n function deleteEligibleTokenAddress(string memory _tokenSymbol)\n public\n virtual\n onlyOwner\n {\n delete eligibleTokenAddresses[_tokenSymbol];\n }\n\n /**\n * @notice Change the TCO2 contracts registry.\n * @param _address The address of the Toucan contract registry to use\n */\n function setToucanContractRegistry(address _address)\n public\n virtual\n onlyOwner\n {\n contractRegistryAddress = _address;\n }\n}\n" - }, - "contracts/OffsetHelperStorage.sol": { - "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(string => address) public eligibleTokenAddresses;\n address public contractRegistryAddress =\n 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;\n address public sushiRouterAddress =\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" - }, - "contracts/test/IWETH.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWETH is IERC20 {\n function deposit() external payable;\n function withdraw(uint256) external;\n}\n" - }, - "contracts/test/Swapper.sol": { - "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\n\ncontract Swapper {\n using SafeERC20 for IERC20;\n\n address public sushiRouterAddress =\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\n mapping(string => address) public tokenAddresses;\n\n constructor(string[] memory _tokenSymbols, address[] memory _tokenAddresses)\n {\n uint256 i = 0;\n while (i < _tokenSymbols.length) {\n tokenAddresses[_tokenSymbols[i]] = _tokenAddresses[i];\n i += 1;\n }\n }\n\n function calculateNeededETHAmount(address _toToken, uint256 _amount)\n public\n view\n returns (uint256)\n {\n IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress);\n\n address[] memory path = generatePath(\n tokenAddresses[\"WMATIC\"],\n _toToken\n );\n\n uint256[] memory amounts = routerSushi.getAmountsIn(_amount, path);\n return amounts[0];\n }\n\n function swap(address _toToken, uint256 _amount) public payable {\n IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress);\n\n address[] memory path = generatePath(\n tokenAddresses[\"WMATIC\"],\n _toToken\n );\n\n uint256[] memory amounts = routerSushi.swapETHForExactTokens{\n value: msg.value\n }(_amount, path, address(this), block.timestamp);\n\n IERC20(_toToken).transfer(msg.sender, _amount);\n\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus ETH back to user.\");\n }\n }\n\n function generatePath(address _fromToken, address _toToken)\n internal\n view\n returns (address[] memory)\n {\n if (_toToken == tokenAddresses[\"USDC\"]) {\n address[] memory path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = _fromToken;\n path[1] = tokenAddresses[\"USDC\"];\n path[2] = _toToken;\n return path;\n }\n }\n\n fallback() external payable {}\n\n receive() external payable {}\n}\n" - }, - "contracts/types/CarbonProjectTypes.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" - }, - "contracts/types/CarbonProjectVintageTypes.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 200 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/mumbai/solcInputs/9768af37541e90e4200434e6de116099.json b/deployments/mumbai/solcInputs/9768af37541e90e4200434e6de116099.json new file mode 100644 index 0000000..0e855da --- /dev/null +++ b/deployments/mumbai/solcInputs/9768af37541e90e4200434e6de116099.json @@ -0,0 +1,89 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\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/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-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/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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanCarbonOffsets.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanContractRegistry.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IToucanPoolToken.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" + }, + "contracts/OffsetHelper.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\n * swap on a DEX).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token e.g., NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n // Chain ID of Celo mainnet\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token e.g., NCT.\n *\n * @param sender The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, e.g., NCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address sender,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Path doesn't yet exists.\");\n\n _;\n }\n\n modifier nativeTokenChain() {\n require(\n block.chainid != CELO_MAINNET_CHAINID,\n \"The function is not available on this network.\"\n );\n\n _;\n }\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _poolAddresses A list of pool token addresses.\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\n * to the provided token symbols.\n */\n constructor(\n address[] memory _poolAddresses,\n string[] memory _tokenSymbolsForPaths,\n address[][] memory _paths,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n poolAddresses = _poolAddresses;\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\n paths = _paths;\n\n uint256 i = 0;\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\n while (i < eligibleSwapPathsBySymbolLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\n i += 1;\n }\n }\n\n // fallback payable and receive method to fix the situation where transfering dust native tokens\n // in the native tokens to token swap fails\n\n receive() external payable {}\n\n fallback() external payable {}\n\n // ----------------------------------------\n // Upgradable related functions\n // ----------------------------------------\n\n function initialize() external virtual initializer {\n __Ownable_init_unchained();\n }\n\n // ----------------------------------------\n // Public functions\n // ----------------------------------------\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\n * to determine how much native tokens e.g., MATIC must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to offset, e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\n * can be used to calculate the expected amount of TCO2s that will be\n * offset using `autoOffsetExactInToken()`.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToSwap\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(\n _fromToken,\n _poolToken,\n _amountToSwap\n );\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n *\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\n * the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\n * to the user. This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(\n address _poolToken,\n uint256 _amountToOffset\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n * All provided native tokens is consumed for offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\n * used to calculate the expected amount of TCO2s that will be offset\n * using `autoOffsetExactInETH()`.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, e.g., NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\n // calculate path & amounts\n (\n address[] memory path,\n uint256[] memory expAmounts\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(dexRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // calculate path & amounts\n\n address[] memory path = generatePath(_fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining native tokens that was not consumed by the swap is returned.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutETH(\n address _poolToken,\n uint256 _toAmount\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\n // create path & amounts\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n // swap\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided native tokens will be swapped.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped native tokens .\n */\n function swapExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // create path & amounts\n uint256 fromAmount = msg.value;\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(\n address _erc20Addr,\n uint256 _amount\n ) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(\n address _fromToken,\n uint256 _amount\n )\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(\n address[] memory _tco2s,\n uint256[] memory _amounts\n ) public {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n // ----------------------------------------\n // Public view functions\n // ----------------------------------------\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, e.g., NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n (, uint256[] memory amounts) = calculateExactOutSwap(\n _fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n (, uint256[] memory amounts) = calculateExactInSwap(\n _fromToken,\n _poolToken,\n _fromAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, e.g., NCT.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of native tokens required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactOutSwap(\n fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\n *\n * @param _fromTokenAmount The amount of native tokens to swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n address _poolToken,\n uint256 _fromTokenAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactInSwap(\n fromToken,\n _poolToken,\n _fromTokenAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Checks if Pool Address is eligible for offsetting.\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\n */\n function isPoolAddressEligible(\n address _poolToken\n ) public view returns (bool _isEligible) {\n _isEligible = isRedeemable(_poolToken);\n }\n\n /**\n * @notice Checks if ERC20 Token is eligible for swapping.\n * @param _erc20Address The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @return _path Returns the path of the token to be exchanged\n */\n function isERC20AddressEligible(\n address _erc20Address\n ) public view returns (address[] memory _path) {\n _path = eligibleSwapPaths[_erc20Address];\n }\n\n // ----------------------------------------\n // Internal methods\n // ----------------------------------------\n\n function calculateExactOutSwap(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n /**\n * @notice Show all pool token addresses that can be used to retired.\n * @param _fromToken a list of token symbols that can be retired.\n * @param _toToken a list of token symbols that can be retired.\n */\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n function dexRouter() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(dexRouterAddress);\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < paths.length; i++) {\n if (paths[i][0] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Cheks if Pool Token is eligible for Offsetting.\n * @param _poolToken The addresses of the pool token to redeem\n * @return _isEligible Returns if token can be redeemed\n */\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible paths and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _path The path of the path to add\n */\n function addPath(\n string memory _tokenSymbol,\n address[] memory _path\n ) public virtual onlyOwner {\n eligibleSwapPaths[_path[0]] = _path;\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\n tokenSymbolsForPaths.push(_tokenSymbol);\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the path to remove\n */\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\n }\n\n /**\n * @notice Change or add pool token addresses.\n * @param _poolToken The address of the pool token to add\n */\n function addPoolToken(address _poolToken) public virtual onlyOwner {\n poolAddresses.push(_poolToken);\n }\n\n /**\n * @notice Delete eligible pool token addresses stored in the contract.\n * @param _poolToken The address of the pool token to remove\n */\n function removePoolToken(address _poolToken) public virtual onlyOwner {\n for (uint256 i; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _poolToken) {\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\n poolAddresses.pop();\n break;\n }\n }\n }\n}\n" + }, + "contracts/OffsetHelperStorage.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(address => address[]) public eligibleSwapPaths;\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\n\n address public dexRouterAddress;\n\n address[] public poolAddresses;\n string[] public tokenSymbolsForPaths;\n address[][] public paths;\n\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" + }, + "contracts/types/CarbonProjectTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" + }, + "contracts/types/CarbonProjectVintageTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/polygon/OffsetHelper.json b/deployments/polygon/OffsetHelper.json index 0a4acc0..f09e542 100644 --- a/deployments/polygon/OffsetHelper.json +++ b/deployments/polygon/OffsetHelper.json @@ -1,17 +1,27 @@ { - "address": "0x4E01404D07c5C85D35a2b6A6Ad777D29CC51Eaa1", + "address": "0x2647768D46Fe7c9A1b4606b3607a13C72a0cc086", "abi": [ { "inputs": [ + { + "internalType": "address[]", + "name": "_poolAddresses", + "type": "address[]" + }, { "internalType": "string[]", - "name": "_eligibleTokenSymbols", + "name": "_tokenSymbolsForPaths", "type": "string[]" }, { - "internalType": "address[]", - "name": "_eligibleTokenAddresses", - "type": "address[]" + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" } ], "stateMutability": "nonpayable", @@ -55,7 +65,7 @@ { "indexed": false, "internalType": "address", - "name": "who", + "name": "sender", "type": "address" }, { @@ -84,6 +94,37 @@ "stateMutability": "payable", "type": "fallback" }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + }, + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "name": "addPath", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + } + ], + "name": "addPoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -115,15 +156,15 @@ "name": "_fromToken", "type": "address" }, - { - "internalType": "uint256", - "name": "_amountToSwap", - "type": "uint256" - }, { "internalType": "address", "name": "_poolToken", "type": "address" + }, + { + "internalType": "uint256", + "name": "_amountToSwap", + "type": "uint256" } ], "name": "autoOffsetExactInToken", @@ -175,7 +216,7 @@ "inputs": [ { "internalType": "address", - "name": "_depositedToken", + "name": "_fromToken", "type": "address" }, { @@ -307,22 +348,22 @@ }, { "inputs": [ - { - "internalType": "uint256", - "name": "_fromMaticAmount", - "type": "uint256" - }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" + }, + { + "internalType": "uint256", + "name": "_fromTokenAmount", + "type": "uint256" } ], "name": "calculateExpectedPoolTokenForETH", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -336,22 +377,22 @@ "name": "_fromToken", "type": "address" }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, { "internalType": "uint256", "name": "_fromAmount", "type": "uint256" - }, - { - "internalType": "address", - "name": "_toToken", - "type": "address" } ], "name": "calculateExpectedPoolTokenForToken", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -362,7 +403,7 @@ "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -375,7 +416,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountIn", "type": "uint256" } ], @@ -391,7 +432,7 @@ }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -404,7 +445,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountIn", "type": "uint256" } ], @@ -412,47 +453,58 @@ "type": "function" }, { - "inputs": [], - "name": "contractRegistryAddress", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "_erc20Addr", "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" } ], - "stateMutability": "view", + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ { - "internalType": "string", - "name": "_tokenSymbol", - "type": "string" + "internalType": "address", + "name": "", + "type": "address" } ], - "name": "deleteEligibleTokenAddress", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "_erc20Addr", + "name": "", "type": "address" }, { "internalType": "uint256", - "name": "_amount", + "name": "", "type": "uint256" } ], - "name": "deposit", - "outputs": [], - "stateMutability": "nonpayable", + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", "type": "function" }, { @@ -461,9 +513,14 @@ "internalType": "string", "name": "", "type": "string" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "eligibleTokenAddresses", + "name": "eligibleSwapPathsBySymbol", "outputs": [ { "internalType": "address", @@ -476,73 +533,143 @@ }, { "inputs": [], - "name": "owner", + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_erc20Address", + "type": "address" + } + ], + "name": "isERC20AddressEligible", "outputs": [ + { + "internalType": "address[]", + "name": "_path", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ { "internalType": "address", - "name": "", + "name": "_poolToken", "type": "address" } ], + "name": "isPoolAddressEligible", + "outputs": [ + { + "internalType": "bool", + "name": "_isEligible", + "type": "bool" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", "type": "function" }, { "inputs": [ { - "internalType": "string", - "name": "_tokenSymbol", - "type": "string" + "internalType": "uint256", + "name": "", + "type": "uint256" }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "paths", + "outputs": [ { "internalType": "address", - "name": "_address", + "name": "", "type": "address" } ], - "name": "setEligibleTokenAddress", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "poolAddresses", + "outputs": [ { "internalType": "address", - "name": "_address", + "name": "", "type": "address" } ], - "name": "setToucanContractRegistry", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_tokenSymbol", + "type": "string" + } + ], + "name": "removePath", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "sushiRouterAddress", - "outputs": [ + "inputs": [ { "internalType": "address", - "name": "", + "name": "_poolToken", "type": "address" } ], - "stateMutability": "view", + "name": "removePoolToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" } ], @@ -550,7 +677,7 @@ "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -564,22 +691,22 @@ "name": "_fromToken", "type": "address" }, + { + "internalType": "address", + "name": "_poolToken", + "type": "address" + }, { "internalType": "uint256", "name": "_fromAmount", "type": "uint256" - }, - { - "internalType": "address", - "name": "_toToken", - "type": "address" } ], "name": "swapExactInToken", "outputs": [ { "internalType": "uint256", - "name": "", + "name": "amountOut", "type": "uint256" } ], @@ -590,7 +717,7 @@ "inputs": [ { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -613,7 +740,7 @@ }, { "internalType": "address", - "name": "_toToken", + "name": "_poolToken", "type": "address" }, { @@ -627,6 +754,25 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenSymbolsForPaths", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -663,87 +809,108 @@ "type": "receive" } ], - "transactionHash": "0x3407146292f88023c8262004678e9c1e1e3f10253573dd18c9497a26058b70a0", + "transactionHash": "0x0758b263c72c52fc9ab64f1f6f24699aa7cd764036baf7b4010a1b6b79cc6f1d", "receipt": { "to": null, - "from": "0x721F6f7A29b99CbdE1F18C4AA7D7AEb31eb2923B", - "contractAddress": "0x4E01404D07c5C85D35a2b6A6Ad777D29CC51Eaa1", - "transactionIndex": 81, - "gasUsed": "2611056", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000108000000000000000000000000000000000000000000000000000000000804000000000000000000100000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000040000000200010040000100000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000100000", - "blockHash": "0xd810ae00faae37eaf957eaa01693d2a9388e93e402db7355784bed960641caba", - "transactionHash": "0x3407146292f88023c8262004678e9c1e1e3f10253573dd18c9497a26058b70a0", + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0x2647768D46Fe7c9A1b4606b3607a13C72a0cc086", + "transactionIndex": 144, + "gasUsed": "3996079", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000800000000000400000000100000000000000000000000000000000000000000000000000000000000080000020000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000100000", + "blockHash": "0x2c88de092f8b0a931b8a26b53ffb24519869761e5766d2947f300c749ee5f02f", + "transactionHash": "0x0758b263c72c52fc9ab64f1f6f24699aa7cd764036baf7b4010a1b6b79cc6f1d", "logs": [ { - "transactionIndex": 81, - "blockNumber": 37621616, - "transactionHash": "0x3407146292f88023c8262004678e9c1e1e3f10253573dd18c9497a26058b70a0", + "transactionIndex": 144, + "blockNumber": 47453936, + "transactionHash": "0x0758b263c72c52fc9ab64f1f6f24699aa7cd764036baf7b4010a1b6b79cc6f1d", "address": "0x0000000000000000000000000000000000001010", "topics": [ "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", - "0x000000000000000000000000721f6f7a29b99cbde1f18c4aa7d7aeb31eb2923b", - "0x00000000000000000000000026c80cc193b27d73d2c40943acec77f4da2c5bd8" + "0x000000000000000000000000101b4c436df747b24d17ce43146da52fa6006c36", + "0x0000000000000000000000007c7379531b2aee82e4ca06d4175d13b9cbeafd49" ], - "data": "0x0000000000000000000000000000000000000000000000000127c69703d18060000000000000000000000000000000000000000000000004f6706ed1a557002a000000000000000000000000000000000000000000000265d90ca9b2fdc7363d000000000000000000000000000000000000000000000004f548a83aa1857fca000000000000000000000000000000000000000000000265da34704a0198b69d", - "logIndex": 295, - "blockHash": "0xd810ae00faae37eaf957eaa01693d2a9388e93e402db7355784bed960641caba" + "data": "0x000000000000000000000000000000000000000000000000011af019a4ad43de0000000000000000000000000000000000000000000000011b319942ba837a2f0000000000000000000000000000000000000000000255b6c29275def3eb25750000000000000000000000000000000000000000000000011a16a92915d636510000000000000000000000000000000000000000000255b6c3ad65f898986953", + "logIndex": 652, + "blockHash": "0x2c88de092f8b0a931b8a26b53ffb24519869761e5766d2947f300c749ee5f02f" } ], - "blockNumber": 37621616, - "cumulativeGasUsed": "17964610", + "blockNumber": 47453936, + "cumulativeGasUsed": "26862822", "status": 1, "byzantium": true }, "args": [ [ - "BCT", - "NCT", + "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", + "0xD838290e877E0188a4A44700463419ED96c16107" + ], + [ "USDC", "WETH", "WMATIC" ], [ - "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", - "0xD838290e877E0188a4A44700463419ED96c16107", - "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", - "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", - "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270" - ] + [ + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ], + [ + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ], + [ + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ] + ], + "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" ], - "numDeployments": 2, - "solcInputHash": "84d45862bdebcae922b40dea008570ca", - "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string[]\",\"name\":\"_eligibleTokenSymbols\",\"type\":\"string[]\"},{\"internalType\":\"address[]\",\"name\":\"_eligibleTokenAddresses\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"who\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_depositedToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fromMaticAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractRegistryAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"deleteEligibleTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"eligibleTokenAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setEligibleTokenAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"}],\"name\":\"setToucanContractRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sushiRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, for example, NCT or BCT\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\",\"who\":\"The sender of the transaction\"}}},\"kind\":\"dev\",\"methods\":{\"autoOffsetExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,uint256,address)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends much MATIC, the leftover amount will be sent back to the user.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_depositedToken\":\"The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to use, for example, NCT or BCT.\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT or BCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(uint256,address)\":{\"params\":{\"_fromMaticAmount\":\"The amount of MATIC to swap\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,uint256,address)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_toAmount\":\"The desired amount of pool token to receive\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"amounts The amount of MATIC required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_toAmount\":\"The desired amount of pool token to receive\",\"_toToken\":\"The address of the pool token to swap for, for example, NCT or BCT\"},\"returns\":{\"_0\":\"amountsIn The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_eligibleTokenAddresses\":\"A list of token addresses corresponding to the provided token symbols.\",\"_eligibleTokenSymbols\":\"A list of token symbols.\"}},\"deleteEligibleTokenAddress(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the token to remove\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"setEligibleTokenAddress(string,address)\":{\"params\":{\"_address\":\"The address of the token to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"setToucanContractRegistry(address)\":{\"params\":{\"_address\":\"The address of the Toucan contract registry to use\"}},\"swapExactInETH(address)\":{\"params\":{\"_toToken\":\"Token to swap for (will be held within contract)\"},\"returns\":{\"_0\":\"Resulting amount of Toucan pool token that got acquired for the swapped MATIC.\"}},\"swapExactInToken(address,uint256,address)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The ERC20 token to deposit and swap\",\"_toToken\":\"The Toucan token to swap for (will be held within contract)\"},\"returns\":{\"_0\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_toAmount\":\"Amount of NCT / BCT wanted\",\"_toToken\":\"Token to swap for (will be held within contract)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The ERC20 oken to deposit and swap\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\",\"_toToken\":\"The token to swap for (will be held within contract)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token such as BCT or NCT.\"}},\"kind\":\"user\",\"methods\":{\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. All provided MATIC is consumed for offsetting. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,uint256,address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). All provided token is consumed for offsetting. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. Use `calculateNeededETHAmount()` first in order to find out how much MATIC is required to retire the specified quantity of TCO2. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in order to find out how much of the ERC20 token is required to retire the specified quantity of TCO2. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, for example, BCT or NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(uint256,address)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of MATIC.\"},\"calculateExpectedPoolTokenForToken(address,uint256,address)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much MATIC is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deleteEligibleTokenAddress(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"setEligibleTokenAddress(string,address)\":{\"notice\":\"Change or add eligible tokens and their addresses.\"},\"setToucanContractRegistry(address)\":{\"notice\":\"Change the TCO2 contracts registry.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided MATIC will be swapped.\"},\"swapExactInToken(address,uint256,address)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining MATIC that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token swap). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token such as BCT or NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using MATIC, specifying the exact amount of TCO2s to retire, - `autoOffsetExactInETH()` if the user would like to perform a retirement using MATIC, swapping all sent MATIC into TCO2s, - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token\\n * swap).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token such as BCT or NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using MATIC, specifying the exact amount of TCO2s to retire,\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using MATIC, swapping all sent MATIC into TCO2s,\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _eligibleTokenSymbols A list of token symbols.\\n * @param _eligibleTokenAddresses A list of token addresses corresponding\\n * to the provided token symbols.\\n */\\n constructor(\\n string[] memory _eligibleTokenSymbols,\\n address[] memory _eligibleTokenAddresses\\n ) {\\n uint256 i = 0;\\n uint256 eligibleTokenSymbolsLen = _eligibleTokenSymbols.length;\\n while (i < eligibleTokenSymbolsLen) {\\n eligibleTokenAddresses[\\n _eligibleTokenSymbols[i]\\n ] = _eligibleTokenAddresses[i];\\n i += 1;\\n }\\n }\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token such as BCT or NCT.\\n *\\n * @param who The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, for example, NCT or BCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address who,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Token not swappable\\\");\\n\\n _;\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in\\n * order to find out how much of the ERC20 token is required to retire the\\n * specified quantity of TCO2.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _depositedToken The address of the ERC20 token that the user sends\\n * (must be one of USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _depositedToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_depositedToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (must be one of USDC, WETH, WMATIC)\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n uint256 _amountToSwap,\\n address _poolToken\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(_fromToken, _amountToSwap, _poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending MATIC.\\n * Use `calculateNeededETHAmount()` first in order to find out how much\\n * MATIC is required to retire the specified quantity of TCO2.\\n *\\n * This function:\\n * 1. Swaps the Matic sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends much MATIC, the leftover amount will be sent back\\n * to the user.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(address _poolToken, uint256 _amountToOffset)\\n public\\n payable\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap MATIC for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending MATIC.\\n * All provided MATIC is consumed for offsetting.\\n *\\n * This function:\\n * 1. Swaps the Matic sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(address _poolToken)\\n public\\n payable\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap MATIC for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, for example, BCT or NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to use, for example, NCT or BCT.\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Checks whether an address can be used by the contract.\\n * @param _erc20Address address of the ERC20 token to be checked\\n * @return True if the address can be used by the contract\\n */\\n function isEligible(address _erc20Address) private view returns (bool) {\\n bool isToucanContract = IToucanContractRegistry(contractRegistryAddress)\\n .checkERC20(_erc20Address);\\n if (isToucanContract) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"BCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"NCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"USDC\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WETH\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WMATIC\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n if (_erc20Address == eligibleTokenAddresses[\\\"USDC\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WETH\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"WMATIC\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n if (_erc20Address == eligibleTokenAddresses[\\\"BCT\\\"]) return true;\\n if (_erc20Address == eligibleTokenAddresses[\\\"NCT\\\"]) return true;\\n return false;\\n }\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, BCT or NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountsIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount\\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n (, uint256[] memory amounts) =\\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\\n return amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @return The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken\\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n (, uint256[] memory amounts) =\\n calculateExactInSwap(_fromToken, _fromAmount, _toToken);\\n return amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The ERC20 oken to deposit and swap\\n * @param _toToken The token to swap for (will be held within contract)\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) {\\n // calculate path & amounts\\n (address[] memory path, uint256[] memory expAmounts) =\\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(sushiRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(sushiRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_toToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The ERC20 token to deposit and swap\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @param _toToken The Toucan token to swap for (will be held within contract)\\n * @return Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken\\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\\n // calculate path & amounts\\n address[] memory path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(sushiRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n uint256 amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_toToken] += amountOut;\\n\\n return amountOut;\\n }\\n\\n // apparently I need a fallback and a receive method to fix the situation where transfering dust MATIC\\n // in the MATIC to token swap fails\\n fallback() external payable {}\\n\\n receive() external payable {}\\n\\n /**\\n * @notice Return how much MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, for example, BCT or NCT.\\n *\\n * @param _toToken The address of the pool token to swap for, for\\n * example, NCT or BCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amounts The amount of MATIC required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(address _toToken, uint256 _toAmount)\\n public\\n view\\n onlyRedeemable(_toToken)\\n returns (uint256)\\n {\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n (, uint256[] memory amounts) =\\n calculateExactOutSwap(fromToken, _toToken, _toAmount);\\n return amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of MATIC.\\n *\\n * @param _fromMaticAmount The amount of MATIC to swap\\n * @param _toToken The address of the pool token to swap for,\\n * for example, NCT or BCT\\n * @return The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n uint256 _fromMaticAmount,\\n address _toToken\\n ) public view onlyRedeemable(_toToken) returns (uint256) {\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n (, uint256[] memory amounts) =\\n calculateExactInSwap(fromToken, _fromMaticAmount, _toToken);\\n return amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining MATIC that was not consumed by the swap is returned.\\n * @param _toToken Token to swap for (will be held within contract)\\n * @param _toAmount Amount of NCT / BCT wanted\\n */\\n function swapExactOutETH(address _toToken, uint256 _toAmount) public payable onlyRedeemable(_toToken) {\\n // calculate path & amounts\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n address[] memory path = generatePath(fromToken, _toToken);\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_toToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided MATIC will be swapped.\\n * @param _toToken Token to swap for (will be held within contract)\\n * @return Resulting amount of Toucan pool token that got acquired for the\\n * swapped MATIC.\\n */\\n function swapExactInETH(address _toToken) public payable onlyRedeemable(_toToken) returns (uint256) {\\n // calculate path & amounts\\n uint256 fromAmount = msg.value;\\n address fromToken = eligibleTokenAddresses[\\\"WMATIC\\\"];\\n address[] memory path = generatePath(fromToken, _toToken);\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = routerSushi().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n uint256 amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_toToken] += amountOut;\\n\\n return amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(address _erc20Addr, uint256 _amount) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT or BCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(address _fromToken, uint256 _amount)\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT or BCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(address[] memory _tco2s, uint256[] memory _amounts)\\n public\\n {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _toToken,\\n uint256 _toAmount)\\n internal view\\n returns (address[] memory path, uint256[] memory amounts)\\n {\\n path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n amounts = routerSushi().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n uint256 _fromAmount,\\n address _toToken)\\n internal view\\n returns (address[] memory path, uint256[] memory amounts)\\n {\\n path = generatePath(_fromToken, _toToken);\\n uint256 len = path.length;\\n\\n amounts = routerSushi().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n function generatePath(address _fromToken, address _toToken)\\n internal\\n view\\n returns (address[] memory)\\n {\\n if (_fromToken == eligibleTokenAddresses[\\\"USDC\\\"]) {\\n address[] memory path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n } else {\\n address[] memory path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleTokenAddresses[\\\"USDC\\\"];\\n path[2] = _toToken;\\n return path;\\n }\\n }\\n\\n function routerSushi() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(sushiRouterAddress);\\n }\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible tokens and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _address The address of the token to add\\n */\\n function setEligibleTokenAddress(\\n string memory _tokenSymbol,\\n address _address\\n ) public virtual onlyOwner {\\n eligibleTokenAddresses[_tokenSymbol] = _address;\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the token to remove\\n */\\n function deleteEligibleTokenAddress(string memory _tokenSymbol)\\n public\\n virtual\\n onlyOwner\\n {\\n delete eligibleTokenAddresses[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change the TCO2 contracts registry.\\n * @param _address The address of the Toucan contract registry to use\\n */\\n function setToucanContractRegistry(address _address)\\n public\\n virtual\\n onlyOwner\\n {\\n contractRegistryAddress = _address;\\n }\\n}\\n\",\"keccak256\":\"0xadfd0f60c2669a43127f6d7aa46d17972a7911b706e74cadac7c130246ef4e8f\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(string => address) public eligibleTokenAddresses;\\n address public contractRegistryAddress =\\n 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;\\n address public sushiRouterAddress =\\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0x5238c0c54f0acbcef34bc9a34380b053ddd26580912462b69e54282db9ecded9\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", - "bytecode": "0x6080604052606680546001600160a01b031990811673263fa1c180889b3a3f46330f32a4a23287e99fc91790915560678054909116731b02da8cb0d097eb8d57a175b88c7d8b479975061790553480156200005957600080fd5b5060405162002ef038038062002ef08339810160408190526200007c91620001c8565b81516000905b808210156200013257828281518110620000ac57634e487b7160e01b600052603260045260246000fd5b60200260200101516065858481518110620000d757634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620000ee9190620002ff565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790556200012a60018362000376565b915062000082565b50505050620003e4565b600082601f8301126200014d578081fd5b8151602062000166620001608362000350565b6200031d565b80838252828201915082860187848660051b890101111562000186578586fd5b855b85811015620001bb5781516001600160a01b0381168114620001a8578788fd5b8452928401929084019060010162000188565b5090979650505050505050565b6000806040808486031215620001dc578283fd5b83516001600160401b0380821115620001f3578485fd5b818601915086601f83011262000207578485fd5b815160206200021a620001608362000350565b8083825282820191508286018b848660051b89010111156200023a57898afd5b895b85811015620002ca5781518781111562000254578b8cfd5b8801603f81018e1362000265578b8cfd5b85810151888111156200027c576200027c620003ce565b62000290601f8201601f191688016200031d565b8181528f8c838501011115620002a4578d8efd5b620002b5828983018e86016200039b565b8652505092840192908401906001016200023c565b505091890151919750909450505080831115620002e5578384fd5b5050620002f5858286016200013c565b9150509250929050565b60008251620003138184602087016200039b565b9190910192915050565b604051601f8201601f191681016001600160401b0381118282101715620003485762000348620003ce565b604052919050565b60006001600160401b038211156200036c576200036c620003ce565b5060051b60200190565b600082198211156200039657634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620003b85781810151838201526020016200039e565b83811115620003c8576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b612afc80620003f46000396000f3fe60806040526004361061018b5760003560e01c80638474c288116100e0578063d26bce3911610084578063eee63f2a11610061578063eee63f2a146104b2578063f04ad9d7146104d2578063f2fde38b146104e5578063f3fef3a31461050557005b8063d26bce391461045f578063d8a90c401461047f578063e882e37b1461049257005b8063a0cd6049116100bd578063a0cd6049146103c7578063a59be914146103e7578063c23f001f14610407578063d08ec4751461043f57005b80638474c288146103695780638aef324c146103895780638da5cb5b146103a957005b806347e7ef2411610147578063690c7e3c11610124578063690c7e3c146102f4578063715018a61461031457806379bbce8f1461032957806382155e7e1461034957005b806347e7ef24146102805780635367cd9c146102a05780635d25309d146102b357005b80631109ec99146101945780631661f818146101c75780631a0fdecc146101e7578063226ee4ef146102075780632e98c8141461023557806346af60701461024857005b3661019257005b005b3480156101a057600080fd5b506101b46101af36600461248e565b610525565b6040519081526020015b60405180910390f35b3480156101d357600080fd5b506101926101e23660046124fa565b6105d2565b3480156101f357600080fd5b506101b461020236600461244e565b6108c4565b34801561021357600080fd5b506102276102223660046124b9565b610957565b6040516101be92919061284c565b61022761024336600461248e565b61098b565b34801561025457600080fd5b50606654610268906001600160a01b031681565b6040516001600160a01b0390911681526020016101be565b34801561028c57600080fd5b5061019261029b36600461248e565b6109b8565b6101926102ae36600461248e565b610a30565b3480156102bf57600080fd5b506102686102ce3660046126cc565b80516020818301810180516065825292820191909301209152546001600160a01b031681565b34801561030057600080fd5b506101b461030f3660046124b9565b610c97565b34801561032057600080fd5b50610192610d22565b34801561033557600080fd5b50606754610268906001600160a01b031681565b34801561035557600080fd5b5061022761036436600461248e565b610d36565b34801561037557600080fd5b5061019261038436600461244e565b610fa2565b34801561039557600080fd5b506101b46103a43660046124b9565b611266565b3480156103b557600080fd5b506033546001600160a01b0316610268565b3480156103d357600080fd5b506102276103e236600461244e565b611414565b3480156103f357600080fd5b506101b461040236600461275c565b611443565b34801561041357600080fd5b506101b4610422366004612416565b606860209081526000928352604080842090915290825290205481565b34801561044b57600080fd5b5061022761045a36600461248e565b6114e0565b34801561046b57600080fd5b5061019261047a3660046126ff565b6114ed565b6101b461048d3660046123f3565b611539565b34801561049e57600080fd5b506101926104ad3660046123f3565b6116be565b3480156104be57600080fd5b506101926104cd3660046126cc565b6116e8565b6102276104e03660046123f3565b611720565b3480156104f157600080fd5b506101926105003660046123f3565b61174f565b34801561051157600080fd5b5061019261052036600461248e565b6117c8565b60008261053181611882565b6105565760405162461bcd60e51b815260040161054d9061290f565b60405180910390fd5b600060656040516105739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b03169050600061059b82878761190d565b915050806000815181106105bf57634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b81518061060f5760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b604482015260640161054d565b8151811461062f5760405162461bcd60e51b815260040161054d9061293d565b60005b818110156108be5782818151811061065a57634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561067257600101610632565b82818151811061069257634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106106e157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156107585760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e636500000000000000604482015260640161054d565b82818151811061077857634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106107c757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546107fe9190612a27565b9250508190555083818151811061082557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf5784838151811061085b57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161088191815260200190565b600060405180830381600087803b15801561089b57600080fd5b505af11580156108af573d6000803e3d6000fd5b50505050806001019050610632565b50505050565b6000836108d081611a4d565b6108ec5760405162461bcd60e51b815260040161054d906128e2565b836108f681611882565b6109125760405162461bcd60e51b815260040161054d9061290f565b600061091f87878761190d565b9150508060008151811061094357634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b6060806000610967868686611266565b90506109738482610d36565b909350915061098283836105d2565b50935093915050565b6060806109988484610a30565b6109a28484610d36565b90925090506109b182826105d2565b9250929050565b816109c281611882565b6109de5760405162461bcd60e51b815260040161054d9061290f565b6109f36001600160a01b038416333085611aeb565b3360009081526068602090815260408083206001600160a01b038716845290915281208054849290610a26908490612a0f565b9091555050505050565b81610a3a81611882565b610a565760405162461bcd60e51b815260040161054d9061290f565b60006065604051610a739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b031690506000610a9a8286611b56565b90506000610ab06067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610ae2949392919061287a565b6000604051808303818588803b158015610afb57600080fd5b505af1158015610b0f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b389190810190612679565b905080600081518110610b5b57634e487b7160e01b600052603260045260246000fd5b6020026020010151341115610c5757600081600081518110610b8d57634e487b7160e01b600052603260045260246000fd5b602002602001015134610ba09190612a27565b604080516000808252602082019283905292935033918491610bc1916127f2565b60006040518083038185875af1925050503d8060008114610bfe576040519150601f19603f3d011682016040523d82523d6000602084013e610c03565b606091505b5050905080610c545760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b0000000000604482015260640161054d565b50505b3360009081526068602090815260408083206001600160a01b038a16845290915281208054879290610c8a908490612a0f565b9091555050505050505050565b600083610ca381611a4d565b610cbf5760405162461bcd60e51b815260040161054d906128e2565b82610cc981611882565b610ce55760405162461bcd60e51b815260040161054d9061290f565b6000610cf2878787611d22565b9150508060018251610d049190612a27565b8151811061094357634e487b7160e01b600052603260045260246000fd5b610d2a611e58565b610d346000611eb2565b565b60608083610d4381611882565b610d5f5760405162461bcd60e51b815260040161054d9061290f565b3360009081526068602090815260408083206001600160a01b0389168452909152902054841115610dd25760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e636500000000604482015260640161054d565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b158015610e1657600080fd5b505af1158015610e2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5291908101906125bd565b3360009081526068602090815260408083206001600160a01b038c168452909152812080549397509195508792610e8a908490612a27565b9091555050835160005b81811015610f5a57848181518110610ebc57634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b031681526020019081526020016000206000888481518110610f0b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f429190612a0f565b90915550819050610f5281612a6a565b915050610e94565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b18833888787604051610f90949392919061280e565b60405180910390a15050509250929050565b82610fac81611a4d565b610fc85760405162461bcd60e51b815260040161054d906128e2565b82610fd281611882565b610fee5760405162461bcd60e51b815260040161054d9061290f565b600080610ffc87878761190d565b9150915060008160008151811061102357634e487b7160e01b600052603260045260246000fd5b602090810291909101015190506110456001600160a01b038916333084611aeb565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b15801561109357600080fd5b505af11580156110a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cb91906126ac565b5060006110e06067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161111395949392919061297e565b600060405180830381600087803b15801561112d57600080fd5b505af1158015611141573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111699190810190612679565b9050818160008151811061118d57634e487b7160e01b600052603260045260246000fd5b602002602001015110156112235760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b1580156111e957600080fd5b505af11580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906126ac565b505b3360009081526068602090815260408083206001600160a01b038c16845290915281208054899290611256908490612a0f565b9091555050505050505050505050565b60008361127281611a4d565b61128e5760405162461bcd60e51b815260040161054d906128e2565b8261129881611882565b6112b45760405162461bcd60e51b815260040161054d9061290f565b60006112c08786611b56565b80519091506112da6001600160a01b03891633308a611aeb565b6067546112f4906001600160a01b038a8116911689611f04565b60006113086067546001600160a01b031690565b6001600160a01b03166338ed17398960008630426040518663ffffffff1660e01b815260040161133c95949392919061297e565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113929190810190612679565b90506000816113a2600185612a27565b815181106113c057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038d168352909352918220805491935083929091611401908490612a0f565b90915550909a9950505050505050505050565b606080611422858585610fa2565b61142c8484610d36565b909250905061143b82826105d2565b935093915050565b60008161144f81611882565b61146b5760405162461bcd60e51b815260040161054d9061290f565b600060656040516114889065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b0316905060006114b0828787611d22565b91505080600182516114c29190612a27565b815181106105bf57634e487b7160e01b600052603260045260246000fd5b60608061099884846109b8565b6114f5611e58565b8060658360405161150691906127f2565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790555050565b60008161154581611882565b6115615760405162461bcd60e51b815260040161054d9061290f565b6040805165574d4154494360d01b81526065600682015290519081900360260190205434906001600160a01b0316600061159b8287611b56565b805190915060006115b46067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b81526004016115e7949392919061287a565b6000604051808303818588803b15801561160057600080fd5b505af1158015611614573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261163d9190810190612679565b905060008161164d600185612a27565b8151811061166b57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038e1683529093529182208054919350839290916116ac908490612a0f565b90915550909998505050505050505050565b6116c6611e58565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b6116f0611e58565b60658160405161170091906127f2565b90815260405190819003602001902080546001600160a01b031916905550565b606080600061172e84611539565b905061173a8482610d36565b909350915061174983836105d2565b50915091565b611757611e58565b6001600160a01b0381166117bc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054d565b6117c581611eb2565b50565b3360009081526068602090815260408083206001600160a01b03861684529091529020548111156118325760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161054d565b6118466001600160a01b038316338361202d565b3360009081526068602090815260408083206001600160a01b038616845290915281208054839290611879908490612a27565b90915550505050565b6000606560405161189c90621090d560ea1b815260030190565b908152604051908190036020019020546001600160a01b03838116911614156118c757506001919050565b604051621390d560ea1b81526065906003015b908152604051908190036020019020546001600160a01b038381169116141561190557506001919050565b506000919050565b60608061191a8585611b56565b80519092506119316067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b815260040161195e929190612965565b60006040518083038186803b15801561197657600080fd5b505afa15801561198a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119b29190810190612679565b9150815181146119d45760405162461bcd60e51b815260040161054d9061293d565b816119e0600183612a27565b815181106119fe57634e487b7160e01b600052603260045260246000fd5b602002602001015184146109825760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b604482015260640161054d565b60006065604051611a6890635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0383811691161415611a9357506001919050565b604051630ae8aa8960e31b8152606590600401908152604051908190036020019020546001600160a01b0383811691161415611ad157506001919050565b60405165574d4154494360d01b81526065906006016118da565b6040516001600160a01b03808516602483015283166044820152606481018290526108be9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205d565b60606065604051611b7190635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0384811691161415611c38576040805160028082526060820183526000926020830190803683370190505090508381600081518110611bd757634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611c1957634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101529050611d1c565b60408051600380825260808201909252600091602082016060803683370190505090508381600081518110611c7d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260408051635553444360e01b815260656004820152905190819003602401902054825191169082906001908110611cda57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600281518110611c1957634e487b7160e01b600052603260045260246000fd5b92915050565b606080611d2f8584611b56565b8051909250611d466067546001600160a01b031690565b6001600160a01b031663d06ca61f86856040518363ffffffff1660e01b8152600401611d73929190612965565b60006040518083038186803b158015611d8b57600080fd5b505afa158015611d9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc79190810190612679565b915081518114611de95760405162461bcd60e51b815260040161054d9061293d565b81600081518110611e0a57634e487b7160e01b600052603260045260246000fd5b602002602001015185146109825760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b604482015260640161054d565b6033546001600160a01b03163314610d345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b801580611f8d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f5357600080fd5b505afa158015611f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8b9190612744565b155b611ff85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161054d565b6040516001600160a01b03831660248201526044810182905261202890849063095ea7b360e01b90606401611b1f565b505050565b6040516001600160a01b03831660248201526044810182905261202890849063a9059cbb60e01b90606401611b1f565b60006120b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661212f9092919063ffffffff16565b80519091501561202857808060200190518101906120d091906126ac565b6120285760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054d565b606061213e8484600085612146565b949350505050565b6060824710156121a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161054d565b600080866001600160a01b031685876040516121c391906127f2565b60006040518083038185875af1925050503d8060008114612200576040519150601f19603f3d011682016040523d82523d6000602084013e612205565b606091505b509150915061221687838387612221565b979650505050505050565b6060831561228d578251612286576001600160a01b0385163b6122865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054d565b508161213e565b61213e83838151156122a25781518083602001fd5b8060405162461bcd60e51b815260040161054d91906128af565b600082601f8301126122cc578081fd5b813560206122e16122dc836129eb565b6129ba565b80838252828201915082860187848660051b8901011115612300578586fd5b855b8581101561231e57813584529284019290840190600101612302565b5090979650505050505050565b600082601f83011261233b578081fd5b8151602061234b6122dc836129eb565b80838252828201915082860187848660051b890101111561236a578586fd5b855b8581101561231e5781518452928401929084019060010161236c565b600082601f830112612398578081fd5b813567ffffffffffffffff8111156123b2576123b2612a9b565b6123c5601f8201601f19166020016129ba565b8181528460208386010111156123d9578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612404578081fd5b813561240f81612ab1565b9392505050565b60008060408385031215612428578081fd5b823561243381612ab1565b9150602083013561244381612ab1565b809150509250929050565b600080600060608486031215612462578081fd5b833561246d81612ab1565b9250602084013561247d81612ab1565b929592945050506040919091013590565b600080604083850312156124a0578182fd5b82356124ab81612ab1565b946020939093013593505050565b6000806000606084860312156124cd578283fd5b83356124d881612ab1565b92506020840135915060408401356124ef81612ab1565b809150509250925092565b6000806040838503121561250c578182fd5b823567ffffffffffffffff80821115612523578384fd5b818501915085601f830112612536578384fd5b813560206125466122dc836129eb565b8083825282820191508286018a848660051b8901011115612565578889fd5b8896505b8487101561259057803561257c81612ab1565b835260019690960195918301918301612569565b50965050860135925050808211156125a6578283fd5b506125b3858286016122bc565b9150509250929050565b600080604083850312156125cf578081fd5b825167ffffffffffffffff808211156125e6578283fd5b818501915085601f8301126125f9578283fd5b815160206126096122dc836129eb565b8083825282820191508286018a848660051b8901011115612628578788fd5b8796505b8487101561265357805161263f81612ab1565b83526001969096019591830191830161262c565b509188015191965090935050508082111561266c578283fd5b506125b38582860161232b565b60006020828403121561268a578081fd5b815167ffffffffffffffff8111156126a0578182fd5b61213e8482850161232b565b6000602082840312156126bd578081fd5b8151801515811461240f578182fd5b6000602082840312156126dd578081fd5b813567ffffffffffffffff8111156126f3578182fd5b61213e84828501612388565b60008060408385031215612711578182fd5b823567ffffffffffffffff811115612727578283fd5b61273385828601612388565b925050602083013561244381612ab1565b600060208284031215612755578081fd5b5051919050565b6000806040838503121561276e578182fd5b82359150602083013561244381612ab1565b6000815180845260208085019450808401835b838110156127b85781516001600160a01b031687529582019590820190600101612793565b509495945050505050565b6000815180845260208085019450808401835b838110156127b8578151875295820195908201906001016127d6565b60008251612804818460208701612a3e565b9190910192915050565b6001600160a01b0385811682528416602082015260806040820181905260009061283a90830185612780565b828103606084015261221681856127c3565b60408152600061285f6040830185612780565b828103602084015261287181856127c3565b95945050505050565b8481526080602082015260006128936080830186612780565b6001600160a01b03949094166040830152506060015292915050565b60208152600082518060208401526128ce816040850160208701612a3e565b601f01601f19169190910160400192915050565b602080825260139082015272546f6b656e206e6f7420737761707061626c6560681b604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b82815260406020820152600061213e6040830184612780565b85815284602082015260a06040820152600061299d60a0830186612780565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156129e3576129e3612a9b565b604052919050565b600067ffffffffffffffff821115612a0557612a05612a9b565b5060051b60200190565b60008219821115612a2257612a22612a85565b500190565b600082821015612a3957612a39612a85565b500390565b60005b83811015612a59578181015183820152602001612a41565b838111156108be5750506000910152565b6000600019821415612a7e57612a7e612a85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117c557600080fdfea26469706673582212205049298921bc98c707274355bc30070e8ecc3d64e22e4f8863e106e9963dfd3064736f6c63430008040033", - "deployedBytecode": "0x60806040526004361061018b5760003560e01c80638474c288116100e0578063d26bce3911610084578063eee63f2a11610061578063eee63f2a146104b2578063f04ad9d7146104d2578063f2fde38b146104e5578063f3fef3a31461050557005b8063d26bce391461045f578063d8a90c401461047f578063e882e37b1461049257005b8063a0cd6049116100bd578063a0cd6049146103c7578063a59be914146103e7578063c23f001f14610407578063d08ec4751461043f57005b80638474c288146103695780638aef324c146103895780638da5cb5b146103a957005b806347e7ef2411610147578063690c7e3c11610124578063690c7e3c146102f4578063715018a61461031457806379bbce8f1461032957806382155e7e1461034957005b806347e7ef24146102805780635367cd9c146102a05780635d25309d146102b357005b80631109ec99146101945780631661f818146101c75780631a0fdecc146101e7578063226ee4ef146102075780632e98c8141461023557806346af60701461024857005b3661019257005b005b3480156101a057600080fd5b506101b46101af36600461248e565b610525565b6040519081526020015b60405180910390f35b3480156101d357600080fd5b506101926101e23660046124fa565b6105d2565b3480156101f357600080fd5b506101b461020236600461244e565b6108c4565b34801561021357600080fd5b506102276102223660046124b9565b610957565b6040516101be92919061284c565b61022761024336600461248e565b61098b565b34801561025457600080fd5b50606654610268906001600160a01b031681565b6040516001600160a01b0390911681526020016101be565b34801561028c57600080fd5b5061019261029b36600461248e565b6109b8565b6101926102ae36600461248e565b610a30565b3480156102bf57600080fd5b506102686102ce3660046126cc565b80516020818301810180516065825292820191909301209152546001600160a01b031681565b34801561030057600080fd5b506101b461030f3660046124b9565b610c97565b34801561032057600080fd5b50610192610d22565b34801561033557600080fd5b50606754610268906001600160a01b031681565b34801561035557600080fd5b5061022761036436600461248e565b610d36565b34801561037557600080fd5b5061019261038436600461244e565b610fa2565b34801561039557600080fd5b506101b46103a43660046124b9565b611266565b3480156103b557600080fd5b506033546001600160a01b0316610268565b3480156103d357600080fd5b506102276103e236600461244e565b611414565b3480156103f357600080fd5b506101b461040236600461275c565b611443565b34801561041357600080fd5b506101b4610422366004612416565b606860209081526000928352604080842090915290825290205481565b34801561044b57600080fd5b5061022761045a36600461248e565b6114e0565b34801561046b57600080fd5b5061019261047a3660046126ff565b6114ed565b6101b461048d3660046123f3565b611539565b34801561049e57600080fd5b506101926104ad3660046123f3565b6116be565b3480156104be57600080fd5b506101926104cd3660046126cc565b6116e8565b6102276104e03660046123f3565b611720565b3480156104f157600080fd5b506101926105003660046123f3565b61174f565b34801561051157600080fd5b5061019261052036600461248e565b6117c8565b60008261053181611882565b6105565760405162461bcd60e51b815260040161054d9061290f565b60405180910390fd5b600060656040516105739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b03169050600061059b82878761190d565b915050806000815181106105bf57634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b81518061060f5760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b604482015260640161054d565b8151811461062f5760405162461bcd60e51b815260040161054d9061293d565b60005b818110156108be5782818151811061065a57634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561067257600101610632565b82818151811061069257634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106106e157634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156107585760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e636500000000000000604482015260640161054d565b82818151811061077857634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b0316815260200190815260200160002060008684815181106107c757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546107fe9190612a27565b9250508190555083818151811061082557634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf5784838151811061085b57634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161088191815260200190565b600060405180830381600087803b15801561089b57600080fd5b505af11580156108af573d6000803e3d6000fd5b50505050806001019050610632565b50505050565b6000836108d081611a4d565b6108ec5760405162461bcd60e51b815260040161054d906128e2565b836108f681611882565b6109125760405162461bcd60e51b815260040161054d9061290f565b600061091f87878761190d565b9150508060008151811061094357634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b6060806000610967868686611266565b90506109738482610d36565b909350915061098283836105d2565b50935093915050565b6060806109988484610a30565b6109a28484610d36565b90925090506109b182826105d2565b9250929050565b816109c281611882565b6109de5760405162461bcd60e51b815260040161054d9061290f565b6109f36001600160a01b038416333085611aeb565b3360009081526068602090815260408083206001600160a01b038716845290915281208054849290610a26908490612a0f565b9091555050505050565b81610a3a81611882565b610a565760405162461bcd60e51b815260040161054d9061290f565b60006065604051610a739065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b031690506000610a9a8286611b56565b90506000610ab06067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610ae2949392919061287a565b6000604051808303818588803b158015610afb57600080fd5b505af1158015610b0f573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610b389190810190612679565b905080600081518110610b5b57634e487b7160e01b600052603260045260246000fd5b6020026020010151341115610c5757600081600081518110610b8d57634e487b7160e01b600052603260045260246000fd5b602002602001015134610ba09190612a27565b604080516000808252602082019283905292935033918491610bc1916127f2565b60006040518083038185875af1925050503d8060008114610bfe576040519150601f19603f3d011682016040523d82523d6000602084013e610c03565b606091505b5050905080610c545760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b0000000000604482015260640161054d565b50505b3360009081526068602090815260408083206001600160a01b038a16845290915281208054879290610c8a908490612a0f565b9091555050505050505050565b600083610ca381611a4d565b610cbf5760405162461bcd60e51b815260040161054d906128e2565b82610cc981611882565b610ce55760405162461bcd60e51b815260040161054d9061290f565b6000610cf2878787611d22565b9150508060018251610d049190612a27565b8151811061094357634e487b7160e01b600052603260045260246000fd5b610d2a611e58565b610d346000611eb2565b565b60608083610d4381611882565b610d5f5760405162461bcd60e51b815260040161054d9061290f565b3360009081526068602090815260408083206001600160a01b0389168452909152902054841115610dd25760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e636500000000604482015260640161054d565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b158015610e1657600080fd5b505af1158015610e2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e5291908101906125bd565b3360009081526068602090815260408083206001600160a01b038c168452909152812080549397509195508792610e8a908490612a27565b9091555050835160005b81811015610f5a57848181518110610ebc57634e487b7160e01b600052603260045260246000fd5b602002602001015160686000336001600160a01b03166001600160a01b031681526020019081526020016000206000888481518110610f0b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610f429190612a0f565b90915550819050610f5281612a6a565b915050610e94565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b18833888787604051610f90949392919061280e565b60405180910390a15050509250929050565b82610fac81611a4d565b610fc85760405162461bcd60e51b815260040161054d906128e2565b82610fd281611882565b610fee5760405162461bcd60e51b815260040161054d9061290f565b600080610ffc87878761190d565b9150915060008160008151811061102357634e487b7160e01b600052603260045260246000fd5b602090810291909101015190506110456001600160a01b038916333084611aeb565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b15801561109357600080fd5b505af11580156110a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110cb91906126ac565b5060006110e06067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161111395949392919061297e565b600060405180830381600087803b15801561112d57600080fd5b505af1158015611141573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111699190810190612679565b9050818160008151811061118d57634e487b7160e01b600052603260045260246000fd5b602002602001015110156112235760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b1580156111e957600080fd5b505af11580156111fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122191906126ac565b505b3360009081526068602090815260408083206001600160a01b038c16845290915281208054899290611256908490612a0f565b9091555050505050505050505050565b60008361127281611a4d565b61128e5760405162461bcd60e51b815260040161054d906128e2565b8261129881611882565b6112b45760405162461bcd60e51b815260040161054d9061290f565b60006112c08786611b56565b80519091506112da6001600160a01b03891633308a611aeb565b6067546112f4906001600160a01b038a8116911689611f04565b60006113086067546001600160a01b031690565b6001600160a01b03166338ed17398960008630426040518663ffffffff1660e01b815260040161133c95949392919061297e565b600060405180830381600087803b15801561135657600080fd5b505af115801561136a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113929190810190612679565b90506000816113a2600185612a27565b815181106113c057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038d168352909352918220805491935083929091611401908490612a0f565b90915550909a9950505050505050505050565b606080611422858585610fa2565b61142c8484610d36565b909250905061143b82826105d2565b935093915050565b60008161144f81611882565b61146b5760405162461bcd60e51b815260040161054d9061290f565b600060656040516114889065574d4154494360d01b815260060190565b908152604051908190036020019020546001600160a01b0316905060006114b0828787611d22565b91505080600182516114c29190612a27565b815181106105bf57634e487b7160e01b600052603260045260246000fd5b60608061099884846109b8565b6114f5611e58565b8060658360405161150691906127f2565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790555050565b60008161154581611882565b6115615760405162461bcd60e51b815260040161054d9061290f565b6040805165574d4154494360d01b81526065600682015290519081900360260190205434906001600160a01b0316600061159b8287611b56565b805190915060006115b46067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b81526004016115e7949392919061287a565b6000604051808303818588803b15801561160057600080fd5b505af1158015611614573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261163d9190810190612679565b905060008161164d600185612a27565b8151811061166b57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101513360009081526068835260408082206001600160a01b038e1683529093529182208054919350839290916116ac908490612a0f565b90915550909998505050505050505050565b6116c6611e58565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b6116f0611e58565b60658160405161170091906127f2565b90815260405190819003602001902080546001600160a01b031916905550565b606080600061172e84611539565b905061173a8482610d36565b909350915061174983836105d2565b50915091565b611757611e58565b6001600160a01b0381166117bc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054d565b6117c581611eb2565b50565b3360009081526068602090815260408083206001600160a01b03861684529091529020548111156118325760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161054d565b6118466001600160a01b038316338361202d565b3360009081526068602090815260408083206001600160a01b038616845290915281208054839290611879908490612a27565b90915550505050565b6000606560405161189c90621090d560ea1b815260030190565b908152604051908190036020019020546001600160a01b03838116911614156118c757506001919050565b604051621390d560ea1b81526065906003015b908152604051908190036020019020546001600160a01b038381169116141561190557506001919050565b506000919050565b60608061191a8585611b56565b80519092506119316067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b815260040161195e929190612965565b60006040518083038186803b15801561197657600080fd5b505afa15801561198a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526119b29190810190612679565b9150815181146119d45760405162461bcd60e51b815260040161054d9061293d565b816119e0600183612a27565b815181106119fe57634e487b7160e01b600052603260045260246000fd5b602002602001015184146109825760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b604482015260640161054d565b60006065604051611a6890635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0383811691161415611a9357506001919050565b604051630ae8aa8960e31b8152606590600401908152604051908190036020019020546001600160a01b0383811691161415611ad157506001919050565b60405165574d4154494360d01b81526065906006016118da565b6040516001600160a01b03808516602483015283166044820152606481018290526108be9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261205d565b60606065604051611b7190635553444360e01b815260040190565b908152604051908190036020019020546001600160a01b0384811691161415611c38576040805160028082526060820183526000926020830190803683370190505090508381600081518110611bd757634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611c1957634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101529050611d1c565b60408051600380825260808201909252600091602082016060803683370190505090508381600081518110611c7d57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260408051635553444360e01b815260656004820152905190819003602401902054825191169082906001908110611cda57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508281600281518110611c1957634e487b7160e01b600052603260045260246000fd5b92915050565b606080611d2f8584611b56565b8051909250611d466067546001600160a01b031690565b6001600160a01b031663d06ca61f86856040518363ffffffff1660e01b8152600401611d73929190612965565b60006040518083038186803b158015611d8b57600080fd5b505afa158015611d9f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611dc79190810190612679565b915081518114611de95760405162461bcd60e51b815260040161054d9061293d565b81600081518110611e0a57634e487b7160e01b600052603260045260246000fd5b602002602001015185146109825760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b604482015260640161054d565b6033546001600160a01b03163314610d345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161054d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b801580611f8d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611f5357600080fd5b505afa158015611f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8b9190612744565b155b611ff85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161054d565b6040516001600160a01b03831660248201526044810182905261202890849063095ea7b360e01b90606401611b1f565b505050565b6040516001600160a01b03831660248201526044810182905261202890849063a9059cbb60e01b90606401611b1f565b60006120b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661212f9092919063ffffffff16565b80519091501561202857808060200190518101906120d091906126ac565b6120285760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161054d565b606061213e8484600085612146565b949350505050565b6060824710156121a75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161054d565b600080866001600160a01b031685876040516121c391906127f2565b60006040518083038185875af1925050503d8060008114612200576040519150601f19603f3d011682016040523d82523d6000602084013e612205565b606091505b509150915061221687838387612221565b979650505050505050565b6060831561228d578251612286576001600160a01b0385163b6122865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161054d565b508161213e565b61213e83838151156122a25781518083602001fd5b8060405162461bcd60e51b815260040161054d91906128af565b600082601f8301126122cc578081fd5b813560206122e16122dc836129eb565b6129ba565b80838252828201915082860187848660051b8901011115612300578586fd5b855b8581101561231e57813584529284019290840190600101612302565b5090979650505050505050565b600082601f83011261233b578081fd5b8151602061234b6122dc836129eb565b80838252828201915082860187848660051b890101111561236a578586fd5b855b8581101561231e5781518452928401929084019060010161236c565b600082601f830112612398578081fd5b813567ffffffffffffffff8111156123b2576123b2612a9b565b6123c5601f8201601f19166020016129ba565b8181528460208386010111156123d9578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612404578081fd5b813561240f81612ab1565b9392505050565b60008060408385031215612428578081fd5b823561243381612ab1565b9150602083013561244381612ab1565b809150509250929050565b600080600060608486031215612462578081fd5b833561246d81612ab1565b9250602084013561247d81612ab1565b929592945050506040919091013590565b600080604083850312156124a0578182fd5b82356124ab81612ab1565b946020939093013593505050565b6000806000606084860312156124cd578283fd5b83356124d881612ab1565b92506020840135915060408401356124ef81612ab1565b809150509250925092565b6000806040838503121561250c578182fd5b823567ffffffffffffffff80821115612523578384fd5b818501915085601f830112612536578384fd5b813560206125466122dc836129eb565b8083825282820191508286018a848660051b8901011115612565578889fd5b8896505b8487101561259057803561257c81612ab1565b835260019690960195918301918301612569565b50965050860135925050808211156125a6578283fd5b506125b3858286016122bc565b9150509250929050565b600080604083850312156125cf578081fd5b825167ffffffffffffffff808211156125e6578283fd5b818501915085601f8301126125f9578283fd5b815160206126096122dc836129eb565b8083825282820191508286018a848660051b8901011115612628578788fd5b8796505b8487101561265357805161263f81612ab1565b83526001969096019591830191830161262c565b509188015191965090935050508082111561266c578283fd5b506125b38582860161232b565b60006020828403121561268a578081fd5b815167ffffffffffffffff8111156126a0578182fd5b61213e8482850161232b565b6000602082840312156126bd578081fd5b8151801515811461240f578182fd5b6000602082840312156126dd578081fd5b813567ffffffffffffffff8111156126f3578182fd5b61213e84828501612388565b60008060408385031215612711578182fd5b823567ffffffffffffffff811115612727578283fd5b61273385828601612388565b925050602083013561244381612ab1565b600060208284031215612755578081fd5b5051919050565b6000806040838503121561276e578182fd5b82359150602083013561244381612ab1565b6000815180845260208085019450808401835b838110156127b85781516001600160a01b031687529582019590820190600101612793565b509495945050505050565b6000815180845260208085019450808401835b838110156127b8578151875295820195908201906001016127d6565b60008251612804818460208701612a3e565b9190910192915050565b6001600160a01b0385811682528416602082015260806040820181905260009061283a90830185612780565b828103606084015261221681856127c3565b60408152600061285f6040830185612780565b828103602084015261287181856127c3565b95945050505050565b8481526080602082015260006128936080830186612780565b6001600160a01b03949094166040830152506060015292915050565b60208152600082518060208401526128ce816040850160208701612a3e565b601f01601f19169190910160400192915050565b602080825260139082015272546f6b656e206e6f7420737761707061626c6560681b604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b82815260406020820152600061213e6040830184612780565b85815284602082015260a06040820152600061299d60a0830186612780565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156129e3576129e3612a9b565b604052919050565b600067ffffffffffffffff821115612a0557612a05612a9b565b5060051b60200190565b60008219821115612a2257612a22612a85565b500190565b600082821015612a3957612a39612a85565b500390565b60005b83811015612a59578181015183820152602001612a41565b838111156108be5750506000910152565b6000600019821415612a7e57612a7e612a85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146117c557600080fdfea26469706673582212205049298921bc98c707274355bc30070e8ecc3d64e22e4f8863e106e9963dfd3064736f6c63430008040033", + "numDeployments": 6, + "solcInputHash": "9768af37541e90e4200434e6de116099", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_poolAddresses\",\"type\":\"address[]\"},{\"internalType\":\"string[]\",\"name\":\"_tokenSymbolsForPaths\",\"type\":\"string[]\"},{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"poolToken\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"Redeemed\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"},{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"name\":\"addPath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"addPoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"autoOffsetExactInETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToSwap\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactInToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutETH\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetExactOutToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amountToOffset\",\"type\":\"uint256\"}],\"name\":\"autoOffsetPoolToken\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"autoRedeem\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tco2s\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"autoRetire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balances\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromTokenAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"calculateExpectedPoolTokenForToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededTokenAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPathsBySymbol\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Address\",\"type\":\"address\"}],\"name\":\"isERC20AddressEligible\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"_path\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"isPoolAddressEligible\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"_isEligible\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"paths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"poolAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"name\":\"removePath\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"removePoolToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"}],\"name\":\"swapExactInETH\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_fromAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactInToken\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_fromToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_poolToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_toAmount\",\"type\":\"uint256\"}],\"name\":\"swapExactOutToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"tokenSymbolsForPaths\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_erc20Addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"params\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"poolToken\":\"The address of the Toucan pool token used in the redemption, e.g., NCT\",\"sender\":\"The sender of the transaction\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}}},\"kind\":\"dev\",\"methods\":{\"addPath(string,address[])\":{\"params\":{\"_path\":\"The path of the path to add\",\"_tokenSymbol\":\"The symbol of the token to add\"}},\"addPoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to add\"}},\"autoOffsetExactInETH(address)\":{\"details\":\"This function is only available on Polygon, not on Celo.\",\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactInToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToSwap\":\"The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutETH(address,uint256)\":{\"details\":\"If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetExactOutToken(address,address,uint256)\":{\"details\":\"When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.\",\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset\",\"_fromToken\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\",\"_poolToken\":\"The address of the Toucan pool token that the user wants to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoOffsetPoolToken(address,uint256)\":{\"params\":{\"_amountToOffset\":\"The amount of TCO2 to offset.\",\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRedeem(address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_amount\":\"Amount to redeem\",\"_fromToken\":\"Could be the address of NCT\"},\"returns\":{\"amounts\":\"An array of the amounts of each TCO2 that were redeemed\",\"tco2s\":\"An array of the TCO2 addresses that were redeemed\"}},\"autoRetire(address[],uint256[])\":{\"params\":{\"_amounts\":\"The amounts to retire from each of the corresponding TCO2 addresses\",\"_tco2s\":\"The addresses of the TCO2s to retire\"}},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"params\":{\"_fromTokenAmount\":\"The amount of native tokens to swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"The expected amount of Pool token that can be acquired\"}},\"calculateNeededETHAmount(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of native tokens required in order to swap for the specified amount of the pool token\"}},\"calculateNeededTokenAmount(address,address,uint256)\":{\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The desired amount of pool token to receive\"},\"returns\":{\"amountIn\":\"The amount of the ERC20 token required in order to swap for the specified amount of the pool token\"}},\"constructor\":{\"details\":\"See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\",\"params\":{\"_paths\":\"An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.\",\"_poolAddresses\":\"A list of pool token addresses.\",\"_tokenSymbolsForPaths\":\"An array of symbols of the token the user want to retire carbon credits for\"}},\"deposit(address,uint256)\":{\"details\":\"Needs to be approved\"},\"isERC20AddressEligible(address)\":{\"params\":{\"_erc20Address\":\"The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\"},\"returns\":{\"_path\":\"Returns the path of the token to be exchanged\"}},\"isPoolAddressEligible(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to offset, e.g., NCT\"},\"returns\":{\"_isEligible\":\"Returns a bool if the Pool token is eligible for offsetting\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"removePath(string)\":{\"params\":{\"_tokenSymbol\":\"The symbol of the path to remove\"}},\"removePoolToken(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to remove\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"swapExactInETH(address)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped native tokens .\"}},\"swapExactInToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side.\",\"params\":{\"_fromAmount\":\"The amount of ERC20 token to swap\",\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\"},\"returns\":{\"amountOut\":\"Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens.\"}},\"swapExactOutETH(address,uint256)\":{\"params\":{\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"swapExactOutToken(address,address,uint256)\":{\"details\":\"Needs to be approved on the client side\",\"params\":{\"_fromToken\":\"The address of the ERC20 token used for the swap\",\"_poolToken\":\"The address of the pool token to swap for, e.g., NCT\",\"_toAmount\":\"The required amount of the Toucan pool token (NCT/BCT)\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"Toucan Protocol Offset Helpers\",\"version\":1},\"userdoc\":{\"events\":{\"Redeemed(address,address,address[],uint256[])\":{\"notice\":\"Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT.\"}},\"kind\":\"user\",\"methods\":{\"addPath(string,address[])\":{\"notice\":\"Change or add eligible paths and their addresses.\"},\"addPoolToken(address)\":{\"notice\":\"Change or add pool token addresses.\"},\"autoOffsetExactInETH(address)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactInToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetExactOutETH(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens.\"},\"autoOffsetExactOutToken(address,address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract.\"},\"autoOffsetPoolToken(address,uint256)\":{\"notice\":\"Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent.\"},\"autoRedeem(address,uint256)\":{\"notice\":\"Redeems the specified amount of NCT / BCT for TCO2.\"},\"autoRetire(address[],uint256[])\":{\"notice\":\"Retire the specified TCO2 tokens.\"},\"calculateExpectedPoolTokenForETH(address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC.\"},\"calculateExpectedPoolTokenForToken(address,address,uint256)\":{\"notice\":\"Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token.\"},\"calculateNeededETHAmount(address,uint256)\":{\"notice\":\"Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT.\"},\"calculateNeededTokenAmount(address,address,uint256)\":{\"notice\":\"Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT.\"},\"constructor\":{\"notice\":\"Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract.\"},\"deposit(address,uint256)\":{\"notice\":\"Allow users to deposit BCT / NCT.\"},\"isERC20AddressEligible(address)\":{\"notice\":\"Checks if ERC20 Token is eligible for swapping.\"},\"isPoolAddressEligible(address)\":{\"notice\":\"Checks if Pool Address is eligible for offsetting.\"},\"removePath(string)\":{\"notice\":\"Delete eligible tokens stored in the contract.\"},\"removePoolToken(address)\":{\"notice\":\"Delete eligible pool token addresses stored in the contract.\"},\"swapExactInETH(address)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped.\"},\"swapExactInToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped.\"},\"swapExactOutETH(address,uint256)\":{\"notice\":\"Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned.\"},\"swapExactOutToken(address,address,uint256)\":{\"notice\":\"Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\"},\"withdraw(address,uint256)\":{\"notice\":\"Allow users to withdraw tokens they have deposited.\"}},\"notice\":\"Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \\\"auto offset\\\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \\\"auto\\\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/OffsetHelper.sol\":\"OffsetHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\\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 function __Ownable_init() internal onlyInitializing {\\n __Ownable_init_unchained();\\n }\\n\\n function __Ownable_init_unchained() internal onlyInitializing {\\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 /**\\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\",\"keccak256\":\"0x247c62047745915c0af6b955470a72d1696ebad4352d7d3011aef1a2463cd888\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\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 * Emits an {Initialized} event the first time it is successfully executed.\\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 /**\\n * @dev Internal function that returns the initialized version. Returns `_initialized`\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Internal function that returns the initialized version. Returns `_initializing`\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0xe798cadb41e2da274913e4b3183a80f50fb057a42238fe8467e077268100ec27\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@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\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\\n */\\n function onERC721Received(\\n address operator,\\n address from,\\n uint256 tokenId,\\n bytes calldata data\\n ) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0xa82b58eca1ee256be466e536706850163d2ec7821945abd6b4778cfb3bee37da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/OffsetHelper.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\nimport \\\"./OffsetHelperStorage.sol\\\";\\nimport \\\"./interfaces/IToucanPoolToken.sol\\\";\\nimport \\\"./interfaces/IToucanCarbonOffsets.sol\\\";\\nimport \\\"./interfaces/IToucanContractRegistry.sol\\\";\\n\\n/**\\n * @title Toucan Protocol Offset Helpers\\n * @notice Helper functions that simplify the carbon offsetting (retirement)\\n * process.\\n *\\n * Retiring carbon tokens requires multiple steps and interactions with\\n * Toucan Protocol's main contracts:\\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\\n * swap on a DEX).\\n * 2. Redeem the pool token for a TCO2 token.\\n * 3. Retire the TCO2 token.\\n *\\n * These steps are combined in each of the following \\\"auto offset\\\" methods\\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\\n * token e.g., NCT,\\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of TCO2s to retire,\\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\\n * of token to swap into TCO2s.\\n *\\n * In these methods, \\\"auto\\\" refers to the fact that these methods use\\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\\n * to the oldest tokenized carbon project in the specfified token pool.\\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\\n *\\n * There are two `view` helper functions `calculateNeededETHAmount()` and\\n * `calculateNeededTokenAmount()` that should be called before using\\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\\n * expected amount of TCO2s that will be offset using functions\\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\\n */\\ncontract OffsetHelper is OffsetHelperStorage {\\n using SafeERC20 for IERC20;\\n // Chain ID of Celo mainnet\\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\\n\\n /**\\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\\n * pool token e.g., NCT.\\n *\\n * @param sender The sender of the transaction\\n * @param poolToken The address of the Toucan pool token used in the\\n * redemption, e.g., NCT\\n * @param tco2s An array of the TCO2 addresses that were redeemed\\n * @param amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n event Redeemed(\\n address sender,\\n address poolToken,\\n address[] tco2s,\\n uint256[] amounts\\n );\\n\\n modifier onlyRedeemable(address _token) {\\n require(isRedeemable(_token), \\\"Token not redeemable\\\");\\n\\n _;\\n }\\n\\n modifier onlySwappable(address _token) {\\n require(isSwappable(_token), \\\"Path doesn't yet exists.\\\");\\n\\n _;\\n }\\n\\n modifier nativeTokenChain() {\\n require(\\n block.chainid != CELO_MAINNET_CHAINID,\\n \\\"The function is not available on this network.\\\"\\n );\\n\\n _;\\n }\\n\\n /**\\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\\n * addresses that can used by the contract.\\n *\\n * @dev See `isEligible()` for a list of tokens that can be used in the\\n * contract. These can be modified after deployment by the contract owner\\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\\n *\\n * @param _poolAddresses A list of pool token addresses.\\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\\n * to the provided token symbols.\\n */\\n constructor(\\n address[] memory _poolAddresses,\\n string[] memory _tokenSymbolsForPaths,\\n address[][] memory _paths,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n poolAddresses = _poolAddresses;\\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\\n paths = _paths;\\n\\n uint256 i = 0;\\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\\n while (i < eligibleSwapPathsBySymbolLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n // fallback payable and receive method to fix the situation where transfering dust native tokens\\n // in the native tokens to token swap fails\\n\\n receive() external payable {}\\n\\n fallback() external payable {}\\n\\n // ----------------------------------------\\n // Upgradable related functions\\n // ----------------------------------------\\n\\n function initialize() external virtual initializer {\\n __Ownable_init_unchained();\\n }\\n\\n // ----------------------------------------\\n // Public functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\\n * to determine how much native tokens e.g., MATIC must be sent to the\\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the Toucan pool token that the\\n * user wants to offset, e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending ERC20\\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\\n * offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\\n * can be used to calculate the expected amount of TCO2s that will be\\n * offset using `autoOffsetExactInToken()`.\\n *\\n * This function:\\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the ERC20 token that is sent to the contract.\\n *\\n * @dev When automatically redeeming pool tokens for the lowest quality\\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\\n * token.\\n *\\n * @param _fromToken The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\\n * token. Full amount will be used for offsetting.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _amountToSwap\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // swap input token for BCT / NCT\\n uint256 amountToOffset = swapExactInToken(\\n _fromToken,\\n _poolToken,\\n _amountToSwap\\n );\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n *\\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\\n * the specified amount of carbon.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\\n * to the user. This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactOutETH(\\n address _poolToken,\\n uint256 _amountToOffset\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n swapExactOutETH(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\\n * All provided native tokens is consumed for offsetting.\\n *\\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\\n * used to calculate the expected amount of TCO2s that will be offset\\n * using `autoOffsetExactInETH()`.\\n *\\n * This function:\\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 3. Retires the TCO2 tokens.\\n *\\n * @dev This function is only available on Polygon, not on Celo.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n // swap native tokens for BCT / NCT\\n uint256 amountToOffset = swapExactInETH(_poolToken);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\\n * tokens available by sending Toucan pool tokens, e.g., NCT.\\n *\\n * This function:\\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\\n * 2. Retires the TCO2 tokens.\\n *\\n * Note: The client must approve the pool token that is sent.\\n *\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @param _amountToOffset The amount of TCO2 to offset.\\n *\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoOffsetPoolToken(\\n address _poolToken,\\n uint256 _amountToOffset\\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\\n // deposit pool token from user to this contract\\n deposit(_poolToken, _amountToOffset);\\n\\n // redeem BCT / NCT for TCO2s\\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\\n\\n // retire the TCO2s to achieve offset\\n autoRetire(tco2s, amounts);\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\\n * @dev Needs to be approved on the client side\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\\n // calculate path & amounts\\n (\\n address[] memory path,\\n uint256[] memory expAmounts\\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\\n uint256 amountIn = expAmounts[0];\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n amountIn\\n );\\n\\n // approve router\\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\\n _toAmount,\\n amountIn, // max. input amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n\\n // remove remaining approval if less input token was consumed\\n if (amounts[0] < amountIn) {\\n IERC20(_fromToken).approve(dexRouterAddress, 0);\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\\n * SushiSwap. All provided ERC20 tokens will be swapped.\\n * @dev Needs to be approved on the client side.\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped ERC20 tokens.\\n */\\n function swapExactInToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // calculate path & amounts\\n\\n address[] memory path = generatePath(_fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // transfer tokens\\n IERC20(_fromToken).safeTransferFrom(\\n msg.sender,\\n address(this),\\n _fromAmount\\n );\\n\\n // approve router\\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\\n _fromAmount,\\n 0, // min. output amount\\n path,\\n address(this),\\n block.timestamp\\n );\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\\n * Remaining native tokens that was not consumed by the swap is returned.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\\n */\\n function swapExactOutETH(\\n address _poolToken,\\n uint256 _toAmount\\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\\n // create path & amounts\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\\n value: msg.value\\n }(_toAmount, path, address(this), block.timestamp);\\n\\n // send surplus back\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus back\\\");\\n }\\n\\n // update balances\\n balances[msg.sender][_poolToken] += _toAmount;\\n }\\n\\n /**\\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\\n * provided native tokens will be swapped.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\\n * swapped native tokens .\\n */\\n function swapExactInETH(\\n address _poolToken\\n )\\n public\\n payable\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n // create path & amounts\\n uint256 fromAmount = msg.value;\\n // wrap the native token\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n address[] memory path = generatePath(fromToken, _poolToken);\\n\\n uint256 len = path.length;\\n\\n // swap\\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\\n value: fromAmount\\n }(0, path, address(this), block.timestamp);\\n amountOut = amounts[len - 1];\\n\\n // update balances\\n balances[msg.sender][_poolToken] += amountOut;\\n }\\n\\n /**\\n * @notice Allow users to withdraw tokens they have deposited.\\n */\\n function withdraw(address _erc20Addr, uint256 _amount) public {\\n require(\\n balances[msg.sender][_erc20Addr] >= _amount,\\n \\\"Insufficient balance\\\"\\n );\\n\\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\\n balances[msg.sender][_erc20Addr] -= _amount;\\n }\\n\\n /**\\n * @notice Allow users to deposit BCT / NCT.\\n * @dev Needs to be approved\\n */\\n function deposit(\\n address _erc20Addr,\\n uint256 _amount\\n ) public onlyRedeemable(_erc20Addr) {\\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\\n balances[msg.sender][_erc20Addr] += _amount;\\n }\\n\\n /**\\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\\n * @dev Needs to be approved on the client side\\n * @param _fromToken Could be the address of NCT\\n * @param _amount Amount to redeem\\n * @return tco2s An array of the TCO2 addresses that were redeemed\\n * @return amounts An array of the amounts of each TCO2 that were redeemed\\n */\\n function autoRedeem(\\n address _fromToken,\\n uint256 _amount\\n )\\n public\\n onlyRedeemable(_fromToken)\\n returns (address[] memory tco2s, uint256[] memory amounts)\\n {\\n require(\\n balances[msg.sender][_fromToken] >= _amount,\\n \\\"Insufficient NCT/BCT balance\\\"\\n );\\n\\n // instantiate pool token (NCT)\\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\\n\\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\\n\\n // update balances\\n balances[msg.sender][_fromToken] -= _amount;\\n uint256 tco2sLen = tco2s.length;\\n for (uint256 index = 0; index < tco2sLen; index++) {\\n balances[msg.sender][tco2s[index]] += amounts[index];\\n }\\n\\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\\n }\\n\\n /**\\n * @notice Retire the specified TCO2 tokens.\\n * @param _tco2s The addresses of the TCO2s to retire\\n * @param _amounts The amounts to retire from each of the corresponding\\n * TCO2 addresses\\n */\\n function autoRetire(\\n address[] memory _tco2s,\\n uint256[] memory _amounts\\n ) public {\\n uint256 tco2sLen = _tco2s.length;\\n require(tco2sLen != 0, \\\"Array empty\\\");\\n\\n require(tco2sLen == _amounts.length, \\\"Arrays unequal\\\");\\n\\n uint256 i = 0;\\n while (i < tco2sLen) {\\n if (_amounts[i] == 0) {\\n unchecked {\\n i++;\\n }\\n continue;\\n }\\n require(\\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\\n \\\"Insufficient TCO2 balance\\\"\\n );\\n\\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\\n\\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n // ----------------------------------------\\n // Public view functions\\n // ----------------------------------------\\n\\n /**\\n * @notice Return how much of the specified ERC20 token is required in\\n * order to swap for the desired amount of a Toucan pool token, for\\n * example, e.g., NCT.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of the ERC20 token required in order to\\n * swap for the specified amount of the pool token\\n */\\n function calculateNeededTokenAmount(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n _fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of ERC20 token.\\n *\\n * @param _fromToken The address of the ERC20 token used for the swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _fromAmount The amount of ERC20 token to swap\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForToken(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n )\\n public\\n view\\n onlySwappable(_fromToken)\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n _fromToken,\\n _poolToken,\\n _fromAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\\n * desired amount of a Toucan pool token, e.g., NCT.\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @param _toAmount The desired amount of pool token to receive\\n * @return amountIn The amount of native tokens required in order to swap for\\n * the specified amount of the pool token\\n */\\n function calculateNeededETHAmount(\\n address _poolToken,\\n uint256 _toAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountIn)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactOutSwap(\\n fromToken,\\n _poolToken,\\n _toAmount\\n );\\n amountIn = amounts[0];\\n }\\n\\n /**\\n * @notice Calculates the expected amount of Toucan Pool token that can be\\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\\n *\\n * @param _fromTokenAmount The amount of native tokens to swap\\n * @param _poolToken The address of the pool token to swap for,\\n * e.g., NCT\\n * @return amountOut The expected amount of Pool token that can be acquired\\n */\\n function calculateExpectedPoolTokenForETH(\\n address _poolToken,\\n uint256 _fromTokenAmount\\n )\\n public\\n view\\n nativeTokenChain\\n onlyRedeemable(_poolToken)\\n returns (uint256 amountOut)\\n {\\n address fromToken = eligibleSwapPathsBySymbol[\\\"WMATIC\\\"][0];\\n (, uint256[] memory amounts) = calculateExactInSwap(\\n fromToken,\\n _poolToken,\\n _fromTokenAmount\\n );\\n amountOut = amounts[amounts.length - 1];\\n }\\n\\n /**\\n * @notice Checks if Pool Address is eligible for offsetting.\\n * @param _poolToken The address of the pool token to offset,\\n * e.g., NCT\\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\\n */\\n function isPoolAddressEligible(\\n address _poolToken\\n ) public view returns (bool _isEligible) {\\n _isEligible = isRedeemable(_poolToken);\\n }\\n\\n /**\\n * @notice Checks if ERC20 Token is eligible for swapping.\\n * @param _erc20Address The address of the ERC20 token that the user sends\\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\\n * @return _path Returns the path of the token to be exchanged\\n */\\n function isERC20AddressEligible(\\n address _erc20Address\\n ) public view returns (address[] memory _path) {\\n _path = eligibleSwapPaths[_erc20Address];\\n }\\n\\n // ----------------------------------------\\n // Internal methods\\n // ----------------------------------------\\n\\n function calculateExactOutSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _toAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsIn(_toAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_toAmount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n }\\n\\n function calculateExactInSwap(\\n address _fromToken,\\n address _poolToken,\\n uint256 _fromAmount\\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\\n // create path & calculate amounts\\n path = generatePath(_fromToken, _poolToken);\\n uint256 len = path.length;\\n\\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\\n\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_fromAmount == amounts[0], \\\"Input amount mismatch\\\");\\n }\\n\\n /**\\n * @notice Show all pool token addresses that can be used to retired.\\n * @param _fromToken a list of token symbols that can be retired.\\n * @param _toToken a list of token symbols that can be retired.\\n */\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n function dexRouter() internal view returns (IUniswapV2Router02) {\\n return IUniswapV2Router02(dexRouterAddress);\\n }\\n\\n /**\\n * @notice Checks whether an address is a Toucan pool token address\\n * @param _erc20Address address of token to be checked\\n * @return True if the address is a Toucan pool token address\\n */\\n function isRedeemable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Checks whether an address can be used in a token swap\\n * @param _erc20Address address of token to be checked\\n * @return True if the specified address can be used in a swap\\n */\\n function isSwappable(address _erc20Address) private view returns (bool) {\\n for (uint i = 0; i < paths.length; i++) {\\n if (paths[i][0] == _erc20Address) {\\n return true;\\n }\\n }\\n\\n return false;\\n }\\n\\n /**\\n * @notice Cheks if Pool Token is eligible for Offsetting.\\n * @param _poolToken The addresses of the pool token to redeem\\n * @return _isEligible Returns if token can be redeemed\\n */\\n\\n // ----------------------------------------\\n // Admin methods\\n // ----------------------------------------\\n\\n /**\\n * @notice Change or add eligible paths and their addresses.\\n * @param _tokenSymbol The symbol of the token to add\\n * @param _path The path of the path to add\\n */\\n function addPath(\\n string memory _tokenSymbol,\\n address[] memory _path\\n ) public virtual onlyOwner {\\n eligibleSwapPaths[_path[0]] = _path;\\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\\n tokenSymbolsForPaths.push(_tokenSymbol);\\n }\\n\\n /**\\n * @notice Delete eligible tokens stored in the contract.\\n * @param _tokenSymbol The symbol of the path to remove\\n */\\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\\n }\\n\\n /**\\n * @notice Change or add pool token addresses.\\n * @param _poolToken The address of the pool token to add\\n */\\n function addPoolToken(address _poolToken) public virtual onlyOwner {\\n poolAddresses.push(_poolToken);\\n }\\n\\n /**\\n * @notice Delete eligible pool token addresses stored in the contract.\\n * @param _poolToken The address of the pool token to remove\\n */\\n function removePoolToken(address _poolToken) public virtual onlyOwner {\\n for (uint256 i; i < poolAddresses.length; i++) {\\n if (poolAddresses[i] == _poolToken) {\\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\\n poolAddresses.pop();\\n break;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x00812c8474fe0303b130513d22e4a8cf4866cb16c3a5099203ef3fd769dc1f8a\",\"license\":\"GPL-3.0\"},\"contracts/OffsetHelperStorage.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2022 Toucan Labs\\n//\\n// SPDX-License-Identifier: GPL-3.0\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\\\";\\n\\ncontract OffsetHelperStorage is OwnableUpgradeable {\\n // token symbol => token address\\n mapping(address => address[]) public eligibleSwapPaths;\\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\\n\\n address public dexRouterAddress;\\n\\n address[] public poolAddresses;\\n string[] public tokenSymbolsForPaths;\\n address[][] public paths;\\n\\n // user => (token => amount)\\n mapping(address => mapping(address => uint256)) public balances;\\n}\\n\",\"keccak256\":\"0xd505f00a17446ca29983779a8febff10114173db7f47ca4300d6a0bfce6b957a\",\"license\":\"GPL-3.0\"},\"contracts/interfaces/IToucanCarbonOffsets.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\nimport \\\"../types/CarbonProjectTypes.sol\\\";\\nimport \\\"../types/CarbonProjectVintageTypes.sol\\\";\\n\\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\\n function getGlobalProjectVintageIdentifiers()\\n external\\n view\\n returns (string memory, string memory);\\n\\n function getAttributes()\\n external\\n view\\n returns (ProjectData memory, VintageData memory);\\n\\n function getRemaining() external view returns (uint256 remaining);\\n\\n function getDepositCap() external view returns (uint256);\\n\\n function retire(uint256 amount) external;\\n\\n function retireFrom(address account, uint256 amount) external;\\n\\n function mintCertificateLegacy(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n\\n function retireAndMintCertificate(\\n string calldata retiringEntityString,\\n address beneficiary,\\n string calldata beneficiaryString,\\n string calldata retirementMessage,\\n uint256 amount\\n ) external;\\n}\\n\",\"keccak256\":\"0x46c4ed2acd84764d0dd68c9c475e2c6ec3229a686046db48aca77ccd298d4b48\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanContractRegistry.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\ninterface IToucanContractRegistry {\\n function carbonOffsetBatchesAddress() external view returns (address);\\n\\n function carbonProjectsAddress() external view returns (address);\\n\\n function carbonProjectVintagesAddress() external view returns (address);\\n\\n function toucanCarbonOffsetsFactoryAddress()\\n external\\n view\\n returns (address);\\n\\n function carbonOffsetBadgesAddress() external view returns (address);\\n\\n function checkERC20(address _address) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa8451ff2527948e4eed26e97247b979212ccb3bd89506302b6c09ddbad392035\",\"license\":\"UNLICENSED\"},\"contracts/interfaces/IToucanPoolToken.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\\\";\\n\\ninterface IToucanPoolToken is IERC20Upgradeable {\\n function deposit(address erc20Addr, uint256 amount) external;\\n\\n function checkEligible(address erc20Addr) external view returns (bool);\\n\\n function checkAttributeMatching(address erc20Addr)\\n external\\n view\\n returns (bool);\\n\\n function calculateRedeemFees(\\n address[] memory tco2s,\\n uint256[] memory amounts\\n ) external view returns (uint256);\\n\\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\\n external;\\n\\n function redeemAuto(uint256 amount) external;\\n\\n function redeemAuto2(uint256 amount)\\n external\\n returns (address[] memory tco2s, uint256[] memory amounts);\\n\\n function getRemaining() external view returns (uint256);\\n\\n function getScoredTCO2s() external view returns (address[] memory);\\n}\\n\",\"keccak256\":\"0xef39949a81cf4ed78d789a1aac5c5860de1582be70de7435f1671931091d43a7\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\n/// @dev CarbonProject related data and attributes\\nstruct ProjectData {\\n string projectId;\\n string standard;\\n string methodology;\\n string region;\\n string storageMethod;\\n string method;\\n string emissionType;\\n string category;\\n string uri;\\n address controller;\\n}\\n\",\"keccak256\":\"0x10d52f79d4bb8dbfe0abbb1662059d6d0193fe5794977b66aacf741451e25401\",\"license\":\"UNLICENSED\"},\"contracts/types/CarbonProjectVintageTypes.sol\":{\"content\":\"// SPDX-FileCopyrightText: 2021 Toucan Labs\\n//\\n// SPDX-License-Identifier: UNLICENSED\\n\\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\\n\\npragma solidity >=0.8.4 <0.9.0;\\n\\nstruct VintageData {\\n /// @dev A human-readable string which differentiates this from other vintages in\\n /// the same project, and helps build the corresponding TCO2 name and symbol.\\n string name;\\n uint64 startTime; // UNIX timestamp\\n uint64 endTime; // UNIX timestamp\\n uint256 projectTokenId;\\n uint64 totalVintageQuantity;\\n bool isCorsiaCompliant;\\n bool isCCPcompliant;\\n string coBenefits;\\n string correspAdjustment;\\n string additionalCertification;\\n string uri;\\n}\\n\",\"keccak256\":\"0x3a52e88a48b87f1ca3992c201f8b786ccf3aeb74796510893f8e33b33eae251b\",\"license\":\"UNLICENSED\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200416338038062004163833981016040819052620000349162000585565b606780546001600160a01b0319166001600160a01b038316179055835162000064906068906020870190620001fd565b5082516200007a90606990602086019062000267565b5081516200009090606a906020850190620002c7565b5082516000905b80821015620001f157838281518110620000c157634e487b7160e01b600052603260045260246000fd5b602002602001015160656000868581518110620000ee57634e487b7160e01b600052603260045260246000fd5b60200260200101516000815181106200011757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020908051906020019062000154929190620001fd565b508382815181106200017657634e487b7160e01b600052603260045260246000fd5b60200260200101516066868481518110620001a157634e487b7160e01b600052603260045260246000fd5b6020026020010151604051620001b89190620006fc565b90815260200160405180910390209080519060200190620001db929190620001fd565b50620001e960018362000773565b915062000097565b5050505050506200081e565b82805482825590600052602060002090810192821562000255579160200282015b828111156200025557825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200021e565b506200026392915062000327565b5090565b828054828255906000526020600020908101928215620002b9579160200282015b82811115620002b95782518051620002a89184916020909101906200033e565b509160200191906001019062000288565b5062000263929150620003bb565b82805482825590600052602060002090810192821562000319579160200282015b8281111562000319578251805162000308918491602090910190620001fd565b5091602001919060010190620002e8565b5062000263929150620003dc565b5b8082111562000263576000815560010162000328565b8280546200034c90620007cb565b90600052602060002090601f01602090048101928262000370576000855562000255565b82601f106200038b57805160ff191683800117855562000255565b8280016001018555821562000255579182015b82811115620002555782518255916020019190600101906200039e565b8082111562000263576000620003d28282620003fd565b50600101620003bb565b8082111562000263576000620003f382826200043f565b50600101620003dc565b5080546200040b90620007cb565b6000825580601f106200041c575050565b601f0160209004906000526020600020908101906200043c919062000327565b50565b50805460008255906000526020600020908101906200043c919062000327565b80516001600160a01b03811681146200047757600080fd5b919050565b600082601f8301126200048d578081fd5b81516020620004a6620004a0836200074d565b6200071a565b80838252828201915082860187848660051b8901011115620004c6578586fd5b855b85811015620004ef57620004dc826200045f565b84529284019290840190600101620004c8565b5090979650505050505050565b600082601f8301126200050d578081fd5b8151602062000520620004a0836200074d565b80838252828201915082860187848660051b890101111562000540578586fd5b855b85811015620004ef5781516001600160401b0381111562000561578788fd5b620005718a87838c01016200047c565b855250928401929084019060010162000542565b600080600080608085870312156200059b578384fd5b84516001600160401b0380821115620005b2578586fd5b620005c0888389016200047c565b95506020870151915080821115620005d6578485fd5b818701915087601f830112620005ea578485fd5b8151620005fb620004a0826200074d565b80828252602082019150602085018b60208560051b88010111156200061e578889fd5b885b84811015620006b65781518681111562000638578a8bfd5b8701603f81018e1362000649578a8bfd5b60208101518781111562000661576200066162000808565b62000676601f8201601f19166020016200071a565b8181528f60408385010111156200068b578c8dfd5b6200069e82602083016040860162000798565b86525050602093840193919091019060010162000620565b505060408a01519097509350505080821115620006d1578384fd5b50620006e087828801620004fc565b925050620006f1606086016200045f565b905092959194509250565b600082516200071081846020870162000798565b9190910192915050565b604051601f8201601f191681016001600160401b038111828210171562000745576200074562000808565b604052919050565b60006001600160401b0382111562000769576200076962000808565b5060051b60200190565b600082198211156200079357634e487b7160e01b81526011600452602481fd5b500190565b60005b83811015620007b55781810151838201526020016200079b565b83811115620007c5576000848401525b50505050565b600181811c90821680620007e057607f821691505b602082108114156200080257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b613935806200082e6000396000f3fe6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", + "deployedBytecode": "0x6080604052600436106101e55760003560e01c80638da5cb5b11610101578063c23f001f1161009a578063e7f67fb11161006c578063e7f67fb1146105ca578063f04ad9d7146105ea578063f2fde38b146105fd578063f3fef3a31461061d578063feb21b9c1461063d57005b8063c23f001f1461053f578063c6c53efb14610577578063d08ec47514610597578063d8a90c40146105b757005b8063a2844a86116100d3578063a2844a86146104af578063b4e76a86146104df578063b8baf9db146104ff578063c0681c3d1461051f57005b80638da5cb5b146104315780639753209d1461044f578063a09457221461046f578063a0cd60491461048f57005b80635367cd9c1161017e578063715018a611610150578063715018a6146103a757806373200b11146103bc5780638129fc1c146103dc57806382155e7e146103f15780638474c2881461041157005b80635367cd9c1461031a57806356a7de0d1461032d57806368d306d91461034d5780636d4565041461037a57005b80632e98c814116101b75780632e98c8141461029957806335bab7e5146102ba57806347e7ef24146102da5780634865b2b4146102fa57005b80631109ec99146101ee5780631357b113146102215780631661f818146102595780631a0fdecc1461027957005b366101ec57005b005b3480156101fa57600080fd5b5061020e6102093660046131f5565b61065d565b6040519081526020015b60405180910390f35b34801561022d57600080fd5b5061024161023c3660046131f5565b610753565b6040516001600160a01b039091168152602001610218565b34801561026557600080fd5b506101ec610274366004613220565b61078b565b34801561028557600080fd5b5061020e6102943660046131b5565b610a7d565b6102ac6102a73660046131f5565b610b10565b6040516102189291906135f2565b3480156102c657600080fd5b5061020e6102d53660046131b5565b610b5f565b3480156102e657600080fd5b506101ec6102f53660046131f5565b610d0a565b34801561030657600080fd5b5061020e6103153660046131b5565b610d82565b6101ec6103283660046131f5565b610e0d565b34801561033957600080fd5b506101ec61034836600461315a565b6110bd565b34801561035957600080fd5b5061036d61036836600461315a565b611209565b60405161021891906135df565b34801561038657600080fd5b5061039a6103953660046134c2565b61127f565b6040516102189190613655565b3480156103b357600080fd5b506101ec61132b565b3480156103c857600080fd5b506102416103d736600461347f565b61133f565b3480156103e857600080fd5b506101ec61136a565b3480156103fd57600080fd5b506102ac61040c3660046131f5565b61147b565b34801561041d57600080fd5b506101ec61042c3660046131b5565b6116e7565b34801561043d57600080fd5b506033546001600160a01b0316610241565b34801561045b57600080fd5b506101ec61046a3660046133f5565b6119ab565b34801561047b57600080fd5b506102ac61048a3660046131b5565b611a4c565b34801561049b57600080fd5b506102ac6104aa3660046131b5565b611a80565b3480156104bb57600080fd5b506104cf6104ca36600461315a565b611aaf565b6040519015158152602001610218565b3480156104eb57600080fd5b5061020e6104fa3660046131f5565b611ac0565b34801561050b57600080fd5b506101ec61051a366004613428565b611ba6565b34801561052b57600080fd5b506101ec61053a36600461315a565b611c8b565b34801561054b57600080fd5b5061020e61055a36600461317d565b606b60209081526000928352604080842090915290825290205481565b34801561058357600080fd5b506102416105923660046134f2565b611ce5565b3480156105a357600080fd5b506102ac6105b23660046131f5565b611d0d565b61020e6105c536600461315a565b611d1a565b3480156105d657600080fd5b50606754610241906001600160a01b031681565b6102ac6105f836600461315a565b611eec565b34801561060957600080fd5b506101ec61061836600461315a565b611f3d565b34801561062957600080fd5b506101ec6106383660046131f5565b611fb3565b34801561064957600080fd5b506102416106583660046134c2565b61206d565b600061a4ec46141561068a5760405162461bcd60e51b815260040161068190613688565b60405180910390fd5b8261069481612097565b6106b05760405162461bcd60e51b81526004016106819061370d565b600060666040516106cd9065574d4154494360d01b815260060190565b90815260200160405180910390206000815481106106fb57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b0316915061071c82878761210f565b9150508060008151811061074057634e487b7160e01b600052603260045260246000fd5b6020026020010151935050505092915050565b6065602052816000526040600020818154811061076f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b8151806107c85760405162461bcd60e51b815260206004820152600b60248201526a417272617920656d70747960a81b6044820152606401610681565b815181146107e85760405162461bcd60e51b81526004016106819061373b565b60005b81811015610a775782818151811061081357634e487b7160e01b600052603260045260246000fd5b60200260200101516000141561082b576001016107eb565b82818151811061084b57634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061089a57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205410156109115760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742054434f322062616c616e6365000000000000006044820152606401610681565b82818151811061093157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061098057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008282546109b79190613825565b925050819055508381815181106109de57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316633790cf57848381518110610a1457634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b8152600401610a3a91815260200190565b600060405180830381600087803b158015610a5457600080fd5b505af1158015610a68573d6000803e3d6000fd5b505050508060010190506107eb565b50505050565b600083610a898161224f565b610aa55760405162461bcd60e51b8152600401610681906136d6565b83610aaf81612097565b610acb5760405162461bcd60e51b81526004016106819061370d565b6000610ad887878761210f565b91505080600081518110610afc57634e487b7160e01b600052603260045260246000fd5b602002602001015193505050509392505050565b60608061a4ec461415610b355760405162461bcd60e51b815260040161068190613688565b610b3f8484610e0d565b610b49848461147b565b9092509050610b58828261078b565b9250929050565b600083610b6b8161224f565b610b875760405162461bcd60e51b8152600401610681906136d6565b83610b9181612097565b610bad5760405162461bcd60e51b81526004016106819061370d565b6000610bb987876122e8565b8051909150610bd36001600160a01b03891633308961289a565b606754610bed906001600160a01b038a8116911688612905565b6000610c016067546001600160a01b031690565b6001600160a01b03166338ed17398860008630426040518663ffffffff1660e01b8152600401610c3595949392919061377c565b600060405180830381600087803b158015610c4f57600080fd5b505af1158015610c63573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c8b91908101906133a2565b905080610c99600184613825565b81518110610cb757634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491985088929091610cf890849061380d565b90915550959998505050505050505050565b81610d1481612097565b610d305760405162461bcd60e51b81526004016106819061370d565b610d456001600160a01b03841633308561289a565b336000908152606b602090815260408083206001600160a01b038716845290915281208054849290610d7890849061380d565b9091555050505050565b600083610d8e8161224f565b610daa5760405162461bcd60e51b8152600401610681906136d6565b83610db481612097565b610dd05760405162461bcd60e51b81526004016106819061370d565b6000610ddd878787612a29565b9150508060018251610def9190613825565b81518110610afc57634e487b7160e01b600052603260045260246000fd5b61a4ec461415610e2f5760405162461bcd60e51b815260040161068190613688565b81610e3981612097565b610e555760405162461bcd60e51b81526004016106819061370d565b60006066604051610e729065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110610ea057634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150610ec082866122e8565b90506000610ed66067546001600160a01b031690565b6001600160a01b031663fb3bdb4134878530426040518663ffffffff1660e01b8152600401610f089493929190613620565b6000604051808303818588803b158015610f2157600080fd5b505af1158015610f35573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052610f5e91908101906133a2565b905080600081518110610f8157634e487b7160e01b600052603260045260246000fd5b602002602001015134111561107d57600081600081518110610fb357634e487b7160e01b600052603260045260246000fd5b602002602001015134610fc69190613825565b604080516000808252602082019283905292935033918491610fe791613585565b60006040518083038185875af1925050503d8060008114611024576040519150601f19603f3d011682016040523d82523d6000602084013e611029565b606091505b505090508061107a5760405162461bcd60e51b815260206004820152601b60248201527f4661696c656420746f2073656e6420737572706c7573206261636b00000000006044820152606401610681565b50505b336000908152606b602090815260408083206001600160a01b038a168452909152812080548792906110b090849061380d565b9091555050505050505050565b6110c5612b5f565b60005b60685481101561120557816001600160a01b0316606882815481106110fd57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156111f3576068805461112890600190613825565b8154811061114657634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606880546001600160a01b03909216918390811061118057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060688054806111cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b806111fd816138a3565b9150506110c8565b5050565b6001600160a01b03811660009081526065602090815260409182902080548351818402810184019094528084526060939283018282801561127357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611255575b50505050509050919050565b6069818154811061128f57600080fd5b9060005260206000200160009150905080546112aa90613868565b80601f01602080910402602001604051908101604052809291908181526020018280546112d690613868565b80156113235780601f106112f857610100808354040283529160200191611323565b820191906000526020600020905b81548152906001019060200180831161130657829003601f168201915b505050505081565b611333612b5f565b61133d6000612bb9565b565b8151602081840181018051606682529282019185019190912091905280548290811061076f57600080fd5b600054610100900460ff161580801561138a5750600054600160ff909116105b806113a45750303b1580156113a4575060005460ff166001145b6114075760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610681565b6000805460ff19166001179055801561142a576000805461ff0019166101001790555b611432612c0b565b8015611478576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6060808361148881612097565b6114a45760405162461bcd60e51b81526004016106819061370d565b336000908152606b602090815260408083206001600160a01b03891684529091529020548411156115175760405162461bcd60e51b815260206004820152601c60248201527f496e73756666696369656e74204e43542f4243542062616c616e6365000000006044820152606401610681565b604051634c02cad160e01b81526004810185905285906001600160a01b03821690634c02cad190602401600060405180830381600087803b15801561155b57600080fd5b505af115801561156f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159791908101906132dc565b336000908152606b602090815260408083206001600160a01b038c1684529091528120805493975091955087926115cf908490613825565b9091555050835160005b8181101561169f5784818151811061160157634e487b7160e01b600052603260045260246000fd5b6020026020010151606b6000336001600160a01b03166001600160a01b03168152602001908152602001600020600088848151811061165057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611687919061380d565b90915550819050611697816138a3565b9150506115d9565b507f3d29f82a20ec733db9f357c4dc1ae0ee60c572cc4b877384aa4639e4d877b188338887876040516116d594939291906135a1565b60405180910390a15050509250929050565b826116f18161224f565b61170d5760405162461bcd60e51b8152600401610681906136d6565b8261171781612097565b6117335760405162461bcd60e51b81526004016106819061370d565b60008061174187878761210f565b9150915060008160008151811061176857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151905061178a6001600160a01b03891633308461289a565b60675460405163095ea7b360e01b81526001600160a01b039182166004820152602481018390529089169063095ea7b390604401602060405180830381600087803b1580156117d857600080fd5b505af11580156117ec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181091906133d5565b5060006118256067546001600160a01b031690565b6001600160a01b0316638803dbee88848730426040518663ffffffff1660e01b815260040161185895949392919061377c565b600060405180830381600087803b15801561187257600080fd5b505af1158015611886573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118ae91908101906133a2565b905081816000815181106118d257634e487b7160e01b600052603260045260246000fd5b602002602001015110156119685760675460405163095ea7b360e01b81526001600160a01b03918216600482015260006024820152908a169063095ea7b390604401602060405180830381600087803b15801561192e57600080fd5b505af1158015611942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196691906133d5565b505b336000908152606b602090815260408083206001600160a01b038c1684529091528120805489929061199b90849061380d565b9091555050505050505050505050565b6119b3612b5f565b606560006066836040516119c79190613585565b90815260200160405180910390206000815481106119f557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040018120611a2291612f0e565b606681604051611a329190613585565b908152602001604051809103902060006114789190612f0e565b6060806000611a5c868686610b5f565b9050611a68858261147b565b9093509150611a77838361078b565b50935093915050565b606080611a8e8585856116e7565b611a98848461147b565b9092509050611aa7828261078b565b935093915050565b6000611aba82612097565b92915050565b600061a4ec461415611ae45760405162461bcd60e51b815260040161068190613688565b82611aee81612097565b611b0a5760405162461bcd60e51b81526004016106819061370d565b60006066604051611b279065574d4154494360d01b815260060190565b9081526020016040518091039020600081548110611b5557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611b76828787612a29565b9150508060018251611b889190613825565b8151811061074057634e487b7160e01b600052603260045260246000fd5b611bae612b5f565b806065600083600081518110611bd457634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000209080519060200190611c0f929190612f2c565b5080606683604051611c219190613585565b90815260200160405180910390209080519060200190611c42929190612f2c565b50606980546001810182556000919091528251611c86917f7fb4302e8e91f9110a6554c2c0a24601252c2a42c2220ca988efcfe39991430801906020850190612f91565b505050565b611c93612b5f565b606880546001810182556000919091527fa2153420d844928b4421650203c77babc8b33d7f2e7b450e2966db0c220977530180546001600160a01b0319166001600160a01b0392909216919091179055565b606a8281548110611cf557600080fd5b90600052602060002001818154811061076f57600080fd5b606080610b3f8484610d0a565b600061a4ec461415611d3e5760405162461bcd60e51b815260040161068190613688565b81611d4881612097565b611d645760405162461bcd60e51b81526004016106819061370d565b60405165574d4154494360d01b815234906000906066906006019081526020016040518091039020600081548110611dac57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546001600160a01b03169150611dcc82876122e8565b80519091506000611de56067546001600160a01b031690565b6001600160a01b0316637ff36ab58660008630426040518663ffffffff1660e01b8152600401611e189493929190613620565b6000604051808303818588803b158015611e3157600080fd5b505af1158015611e45573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052611e6e91908101906133a2565b905080611e7c600184613825565b81518110611e9a57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151336000908152606b835260408082206001600160a01b038d168352909352918220805491995089929091611edb90849061380d565b909155509698975050505050505050565b60608061a4ec461415611f115760405162461bcd60e51b815260040161068190613688565b6000611f1c84611d1a565b9050611f28848261147b565b9093509150611f37838361078b565b50915091565b611f45612b5f565b6001600160a01b038116611faa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610681565b61147881612bb9565b336000908152606b602090815260408083206001600160a01b038616845290915290205481111561201d5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610681565b6120316001600160a01b0383163383612c7f565b336000908152606b602090815260408083206001600160a01b038616845290915281208054839290612064908490613825565b90915550505050565b6068818154811061207d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805b60685481101561210657826001600160a01b0316606882815481106120d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156120f45750600192915050565b806120fe816138a3565b91505061209b565b50600092915050565b60608061211c85856122e8565b80519092506121336067546001600160a01b031690565b6001600160a01b0316631f00ca7485856040518363ffffffff1660e01b8152600401612160929190613763565b60006040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121b491908101906133a2565b9150815181146121d65760405162461bcd60e51b81526004016106819061373b565b816121e2600183613825565b8151811061220057634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b6044820152606401610681565b6000805b606a5481101561210657826001600160a01b0316606a828154811061228857634e487b7160e01b600052603260045260246000fd5b906000526020600020016000815481106122b257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031614156122d65750600192915050565b806122e0816138a3565b915050612253565b6001600160a01b03821660009081526065602052604090205460609060018114156123b7576040805160028082526060820183529091602083019080368337019050509150838260008151811061234f57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061239157634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505050611aba565b80600214156124d057604080516003808252608082019092529060208201606080368337019050509150838260008151811061240357634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061244f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061248e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061239157634e487b7160e01b600052603260045260246000fd5b806003141561267457604080516003808252608082019092529060208201606080368337019050509150838260008151811061251c57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061256857634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106125a757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152606590915260409020805460029081106125f357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260028151811061263257634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061239157634e487b7160e01b600052603260045260246000fd5b60408051600480825260a08201909252906020820160808036833701905050915083826000815181106126b757634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600190811061270357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061274257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600290811061278e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106127cd57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081526065909152604090208054600390811061281957634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260038151811061285857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061239157634e487b7160e01b600052603260045260246000fd5b6040516001600160a01b0380851660248301528316604482015260648101829052610a779085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612caf565b80158061298e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561295457600080fd5b505afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c91906134da565b155b6129f95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610681565b6040516001600160a01b038316602482015260448101829052611c8690849063095ea7b360e01b906064016128ce565b606080612a3685856122e8565b8051909250612a4d6067546001600160a01b031690565b6001600160a01b031663d06ca61f85856040518363ffffffff1660e01b8152600401612a7a929190613763565b60006040518083038186803b158015612a9257600080fd5b505afa158015612aa6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612ace91908101906133a2565b915081518114612af05760405162461bcd60e51b81526004016106819061373b565b81600081518110612b1157634e487b7160e01b600052603260045260246000fd5b60200260200101518414611a775760405162461bcd60e51b8152602060048201526015602482015274092dce0eae840c2dadeeadce840dad2e6dac2e8c6d605b1b6044820152606401610681565b6033546001600160a01b0316331461133d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610681565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16612c765760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610681565b61133d33612bb9565b6040516001600160a01b038316602482015260448101829052611c8690849063a9059cbb60e01b906064016128ce565b6000612d04826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d819092919063ffffffff16565b805190915015611c865780806020019051810190612d2291906133d5565b611c865760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610681565b6060612d908484600085612d98565b949350505050565b606082471015612df95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610681565b600080866001600160a01b03168587604051612e159190613585565b60006040518083038185875af1925050503d8060008114612e52576040519150601f19603f3d011682016040523d82523d6000602084013e612e57565b606091505b5091509150612e6887838387612e73565b979650505050505050565b60608315612edf578251612ed8576001600160a01b0385163b612ed85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610681565b5081612d90565b612d908383815115612ef45781518083602001fd5b8060405162461bcd60e51b81526004016106819190613655565b50805460008255906000526020600020908101906114789190613005565b828054828255906000526020600020908101928215612f81579160200282015b82811115612f8157825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612f4c565b50612f8d929150613005565b5090565b828054612f9d90613868565b90600052602060002090601f016020900481019282612fbf5760008555612f81565b82601f10612fd857805160ff1916838001178555612f81565b82800160010185558215612f81579182015b82811115612f81578251825591602001919060010190612fea565b5b80821115612f8d5760008155600101613006565b600082601f83011261302a578081fd5b8135602061303f61303a836137e9565b6137b8565b80838252828201915082860187848660051b890101111561305e578586fd5b855b85811015613085578135613073816138ea565b84529284019290840190600101613060565b5090979650505050505050565b600082601f8301126130a2578081fd5b815160206130b261303a836137e9565b80838252828201915082860187848660051b89010111156130d1578586fd5b855b85811015613085578151845292840192908401906001016130d3565b600082601f8301126130ff578081fd5b813567ffffffffffffffff811115613119576131196138d4565b61312c601f8201601f19166020016137b8565b818152846020838601011115613140578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561316b578081fd5b8135613176816138ea565b9392505050565b6000806040838503121561318f578081fd5b823561319a816138ea565b915060208301356131aa816138ea565b809150509250929050565b6000806000606084860312156131c9578081fd5b83356131d4816138ea565b925060208401356131e4816138ea565b929592945050506040919091013590565b60008060408385031215613207578182fd5b8235613212816138ea565b946020939093013593505050565b60008060408385031215613232578182fd5b823567ffffffffffffffff80821115613249578384fd5b6132558683870161301a565b935060209150818501358181111561326b578384fd5b85019050601f8101861361327d578283fd5b803561328b61303a826137e9565b80828252848201915084840189868560051b87010111156132aa578687fd5b8694505b838510156132cc5780358352600194909401939185019185016132ae565b5080955050505050509250929050565b600080604083850312156132ee578182fd5b825167ffffffffffffffff80821115613305578384fd5b818501915085601f830112613318578384fd5b8151602061332861303a836137e9565b8083825282820191508286018a848660051b8901011115613347578889fd5b8896505b8487101561337257805161335e816138ea565b83526001969096019591830191830161334b565b509188015191965090935050508082111561338b578283fd5b5061339885828601613092565b9150509250929050565b6000602082840312156133b3578081fd5b815167ffffffffffffffff8111156133c9578182fd5b612d9084828501613092565b6000602082840312156133e6578081fd5b81518015158114613176578182fd5b600060208284031215613406578081fd5b813567ffffffffffffffff81111561341c578182fd5b612d90848285016130ef565b6000806040838503121561343a578182fd5b823567ffffffffffffffff80821115613451578384fd5b61345d868387016130ef565b93506020850135915080821115613472578283fd5b506133988582860161301a565b60008060408385031215613491578182fd5b823567ffffffffffffffff8111156134a7578283fd5b6134b3858286016130ef565b95602094909401359450505050565b6000602082840312156134d3578081fd5b5035919050565b6000602082840312156134eb578081fd5b5051919050565b60008060408385031215613504578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561354b5781516001600160a01b031687529582019590820190600101613526565b509495945050505050565b6000815180845260208085019450808401835b8381101561354b57815187529582019590820190600101613569565b6000825161359781846020870161383c565b9190910192915050565b6001600160a01b038581168252841660208201526080604082018190526000906135cd90830185613513565b8281036060840152612e688185613556565b6020815260006131766020830184613513565b6040815260006136056040830185613513565b82810360208401526136178185613556565b95945050505050565b8481526080602082015260006136396080830186613513565b6001600160a01b03949094166040830152506060015292915050565b602081526000825180602084015261367481604085016020870161383c565b601f01601f19169190910160400192915050565b6020808252602e908201527f5468652066756e6374696f6e206973206e6f7420617661696c61626c65206f6e60408201526d103a3434b9903732ba3bb7b9359760911b606082015260800190565b60208082526018908201527f5061746820646f65736e277420796574206578697374732e0000000000000000604082015260600190565b602080825260149082015273546f6b656e206e6f742072656465656d61626c6560601b604082015260600190565b6020808252600e908201526d105c9c985e5cc81d5b995c5d585b60921b604082015260600190565b828152604060208201526000612d906040830184613513565b85815284602082015260a06040820152600061379b60a0830186613513565b6001600160a01b0394909416606083015250608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156137e1576137e16138d4565b604052919050565b600067ffffffffffffffff821115613803576138036138d4565b5060051b60200190565b60008219821115613820576138206138be565b500190565b600082821015613837576138376138be565b500390565b60005b8381101561385757818101518382015260200161383f565b83811115610a775750506000910152565b600181811c9082168061387c57607f821691505b6020821081141561389d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156138b7576138b76138be565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461147857600080fdfea26469706673582212200f2bb74b64168c68a4845864d66a79cf1c4ab79c19c33d5a3cd70163e4a3de7564736f6c63430008040033", "devdoc": { "events": { "Redeemed(address,address,address[],uint256[])": { "params": { "amounts": "An array of the amounts of each TCO2 that were redeemed", - "poolToken": "The address of the Toucan pool token used in the redemption, for example, NCT or BCT", - "tco2s": "An array of the TCO2 addresses that were redeemed", - "who": "The sender of the transaction" + "poolToken": "The address of the Toucan pool token used in the redemption, e.g., NCT", + "sender": "The sender of the transaction", + "tco2s": "An array of the TCO2 addresses that were redeemed" } } }, "kind": "dev", "methods": { + "addPath(string,address[])": { + "params": { + "_path": "The path of the path to add", + "_tokenSymbol": "The symbol of the token to add" + } + }, + "addPoolToken(address)": { + "params": { + "_poolToken": "The address of the pool token to add" + } + }, "autoOffsetExactInETH(address)": { + "details": "This function is only available on Polygon, not on Celo.", "params": { - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", "tco2s": "An array of the TCO2 addresses that were redeemed" } }, - "autoOffsetExactInToken(address,uint256,address)": { + "autoOffsetExactInToken(address,address,uint256)": { "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", "params": { "_amountToSwap": "The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting.", - "_fromToken": "The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT" + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -751,10 +918,10 @@ } }, "autoOffsetExactOutETH(address,uint256)": { - "details": "If the user sends much MATIC, the leftover amount will be sent back to the user.", + "details": "If the user sends too much native tokens , the leftover amount will be sent back to the user. This function is only available on Polygon, not on Celo.", "params": { "_amountToOffset": "The amount of TCO2 to offset.", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -765,8 +932,8 @@ "details": "When automatically redeeming pool tokens for the lowest quality TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool token.", "params": { "_amountToOffset": "The amount of TCO2 to offset", - "_depositedToken": "The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC)", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT" + "_fromToken": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)", + "_poolToken": "The address of the Toucan pool token that the user wants to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -776,7 +943,7 @@ "autoOffsetPoolToken(address,uint256)": { "params": { "_amountToOffset": "The amount of TCO2 to offset.", - "_poolToken": "The address of the Toucan pool token that the user wants to use, for example, NCT or BCT." + "_poolToken": "The address of the pool token to offset, e.g., NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -787,7 +954,7 @@ "details": "Needs to be approved on the client side", "params": { "_amount": "Amount to redeem", - "_fromToken": "Could be the address of NCT or BCT" + "_fromToken": "Could be the address of NCT" }, "returns": { "amounts": "An array of the amounts of each TCO2 that were redeemed", @@ -800,107 +967,118 @@ "_tco2s": "The addresses of the TCO2s to retire" } }, - "calculateExpectedPoolTokenForETH(uint256,address)": { + "calculateExpectedPoolTokenForETH(address,uint256)": { "params": { - "_fromMaticAmount": "The amount of MATIC to swap", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_fromTokenAmount": "The amount of native tokens to swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "The expected amount of Pool token that can be acquired" + "amountOut": "The expected amount of Pool token that can be acquired" } }, - "calculateExpectedPoolTokenForToken(address,uint256,address)": { + "calculateExpectedPoolTokenForToken(address,address,uint256)": { "params": { "_fromAmount": "The amount of ERC20 token to swap", "_fromToken": "The address of the ERC20 token used for the swap", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "The expected amount of Pool token that can be acquired" + "amountOut": "The expected amount of Pool token that can be acquired" } }, "calculateNeededETHAmount(address,uint256)": { "params": { - "_toAmount": "The desired amount of pool token to receive", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" }, "returns": { - "_0": "amounts The amount of MATIC required in order to swap for the specified amount of the pool token" + "amountIn": "The amount of native tokens required in order to swap for the specified amount of the pool token" } }, "calculateNeededTokenAmount(address,address,uint256)": { "params": { "_fromToken": "The address of the ERC20 token used for the swap", - "_toAmount": "The desired amount of pool token to receive", - "_toToken": "The address of the pool token to swap for, for example, NCT or BCT" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The desired amount of pool token to receive" }, "returns": { - "_0": "amountsIn The amount of the ERC20 token required in order to swap for the specified amount of the pool token" + "amountIn": "The amount of the ERC20 token required in order to swap for the specified amount of the pool token" } }, "constructor": { "details": "See `isEligible()` for a list of tokens that can be used in the contract. These can be modified after deployment by the contract owner using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.", "params": { - "_eligibleTokenAddresses": "A list of token addresses corresponding to the provided token symbols.", - "_eligibleTokenSymbols": "A list of token symbols." + "_paths": "An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols.", + "_poolAddresses": "A list of pool token addresses.", + "_tokenSymbolsForPaths": "An array of symbols of the token the user want to retire carbon credits for" } }, - "deleteEligibleTokenAddress(string)": { + "deposit(address,uint256)": { + "details": "Needs to be approved" + }, + "isERC20AddressEligible(address)": { "params": { - "_tokenSymbol": "The symbol of the token to remove" + "_erc20Address": "The address of the ERC20 token that the user sends (e.g., cUSD, cUSD, USDC, WETH, WMATIC)" + }, + "returns": { + "_path": "Returns the path of the token to be exchanged" } }, - "deposit(address,uint256)": { - "details": "Needs to be approved" + "isPoolAddressEligible(address)": { + "params": { + "_poolToken": "The address of the pool token to offset, e.g., NCT" + }, + "returns": { + "_isEligible": "Returns a bool if the Pool token is eligible for offsetting" + } }, "owner()": { "details": "Returns the address of the current owner." }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." - }, - "setEligibleTokenAddress(string,address)": { + "removePath(string)": { "params": { - "_address": "The address of the token to add", - "_tokenSymbol": "The symbol of the token to add" + "_tokenSymbol": "The symbol of the path to remove" } }, - "setToucanContractRegistry(address)": { + "removePoolToken(address)": { "params": { - "_address": "The address of the Toucan contract registry to use" + "_poolToken": "The address of the pool token to remove" } }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, "swapExactInETH(address)": { "params": { - "_toToken": "Token to swap for (will be held within contract)" + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "Resulting amount of Toucan pool token that got acquired for the swapped MATIC." + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped native tokens ." } }, - "swapExactInToken(address,uint256,address)": { + "swapExactInToken(address,address,uint256)": { "details": "Needs to be approved on the client side.", "params": { "_fromAmount": "The amount of ERC20 token to swap", - "_fromToken": "The ERC20 token to deposit and swap", - "_toToken": "The Toucan token to swap for (will be held within contract)" + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT" }, "returns": { - "_0": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." + "amountOut": "Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens." } }, "swapExactOutETH(address,uint256)": { "params": { - "_toAmount": "Amount of NCT / BCT wanted", - "_toToken": "Token to swap for (will be held within contract)" + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" } }, "swapExactOutToken(address,address,uint256)": { "details": "Needs to be approved on the client side", "params": { - "_fromToken": "The ERC20 oken to deposit and swap", - "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)", - "_toToken": "The token to swap for (will be held within contract)" + "_fromToken": "The address of the ERC20 token used for the swap", + "_poolToken": "The address of the pool token to swap for, e.g., NCT", + "_toAmount": "The required amount of the Toucan pool token (NCT/BCT)" } }, "transferOwnership(address)": { @@ -913,25 +1091,31 @@ "userdoc": { "events": { "Redeemed(address,address,address[],uint256[])": { - "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token such as BCT or NCT." + "notice": "Emitted upon successful redemption of TCO2 tokens from a Toucan pool token e.g., NCT." } }, "kind": "user", "methods": { + "addPath(string,address[])": { + "notice": "Change or add eligible paths and their addresses." + }, + "addPoolToken(address)": { + "notice": "Change or add pool token addresses." + }, "autoOffsetExactInETH(address)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. All provided MATIC is consumed for offsetting. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. All provided native tokens is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForETH()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInETH()`. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." }, - "autoOffsetExactInToken(address,uint256,address)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). All provided token is consumed for offsetting. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + "autoOffsetExactInToken(address,address,uint256)": { + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for offsetting. The `view` helper function `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using `autoOffsetExactInToken()`. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." }, "autoOffsetExactOutETH(address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending MATIC. Use `calculateNeededETHAmount()` first in order to find out how much MATIC is required to retire the specified quantity of TCO2. This function: 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC. The `view` helper function `calculateNeededETHAmount()` should be called before using `autoOffsetExactOutETH()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens." }, "autoOffsetExactOutToken(address,address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in order to find out how much of the ERC20 token is required to retire the specified quantity of TCO2. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available from the specified Toucan token pool by sending ERC20 tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. This function: 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. Note: The client must approve the ERC20 token that is sent to the contract." }, "autoOffsetPoolToken(address,uint256)": { - "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, for example, BCT or NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." + "notice": "Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, e.g., NCT. This function: 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. Note: The client must approve the pool token that is sent." }, "autoRedeem(address,uint256)": { "notice": "Redeems the specified amount of NCT / BCT for TCO2." @@ -939,41 +1123,44 @@ "autoRetire(address[],uint256[])": { "notice": "Retire the specified TCO2 tokens." }, - "calculateExpectedPoolTokenForETH(uint256,address)": { - "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of MATIC." + "calculateExpectedPoolTokenForETH(address,uint256)": { + "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of native tokens e.g., MATIC." }, - "calculateExpectedPoolTokenForToken(address,uint256,address)": { + "calculateExpectedPoolTokenForToken(address,address,uint256)": { "notice": "Calculates the expected amount of Toucan Pool token that can be acquired by swapping the provided amount of ERC20 token." }, "calculateNeededETHAmount(address,uint256)": { - "notice": "Return how much MATIC is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT." + "notice": "Return how much native tokens e.g, MATIC is required in order to swap for the desired amount of a Toucan pool token, e.g., NCT." }, "calculateNeededTokenAmount(address,address,uint256)": { - "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, BCT or NCT." + "notice": "Return how much of the specified ERC20 token is required in order to swap for the desired amount of a Toucan pool token, for example, e.g., NCT." }, "constructor": { "notice": "Contract constructor. Should specify arrays of ERC20 symbols and addresses that can used by the contract." }, - "deleteEligibleTokenAddress(string)": { - "notice": "Delete eligible tokens stored in the contract." - }, "deposit(address,uint256)": { "notice": "Allow users to deposit BCT / NCT." }, - "setEligibleTokenAddress(string,address)": { - "notice": "Change or add eligible tokens and their addresses." + "isERC20AddressEligible(address)": { + "notice": "Checks if ERC20 Token is eligible for swapping." + }, + "isPoolAddressEligible(address)": { + "notice": "Checks if Pool Address is eligible for offsetting." + }, + "removePath(string)": { + "notice": "Delete eligible tokens stored in the contract." }, - "setToucanContractRegistry(address)": { - "notice": "Change the TCO2 contracts registry." + "removePoolToken(address)": { + "notice": "Delete eligible pool token addresses stored in the contract." }, "swapExactInETH(address)": { - "notice": "Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided MATIC will be swapped." + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided native tokens will be swapped." }, - "swapExactInToken(address,uint256,address)": { + "swapExactInToken(address,address,uint256)": { "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap. All provided ERC20 tokens will be swapped." }, "swapExactOutETH(address,uint256)": { - "notice": "Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining MATIC that was not consumed by the swap is returned." + "notice": "Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. Remaining native tokens that was not consumed by the swap is returned." }, "swapExactOutToken(address,address,uint256)": { "notice": "Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap" @@ -982,13 +1169,13 @@ "notice": "Allow users to withdraw tokens they have deposited." } }, - "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token swap). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token such as BCT or NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using MATIC, specifying the exact amount of TCO2s to retire, - `autoOffsetExactInETH()` if the user would like to perform a retirement using MATIC, swapping all sent MATIC into TCO2s, - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", + "notice": "Helper functions that simplify the carbon offsetting (retirement) process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: 1. Obtain a Toucan pool token e.g., NCT (by performing a token swap on a DEX). 2. Redeem the pool token for a TCO2 token. 3. Retire the TCO2 token. These steps are combined in each of the following \"auto offset\" methods implemented in `OffsetHelper` to allow a retirement within one transaction: - `autoOffsetPoolToken()` if the user already owns a Toucan pool token e.g., NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo), - `autoOffsetExactInETH()` if the user would like to perform a retirement using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo), - `autoOffsetExactOutToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of TCO2s to retire, - `autoOffsetExactInToken()` if the user would like to perform a retirement using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount of token to swap into TCO2s. In these methods, \"auto\" refers to the fact that these methods use `autoRedeem()` in order to automatically choose a TCO2 token corresponding to the oldest tokenized carbon project in the specfified token pool. There are no fees incurred by the user when using `autoRedeem()`, i.e., the user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed. There are two `view` helper functions `calculateNeededETHAmount()` and `calculateNeededTokenAmount()` that should be called before using `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the `OffsetHelper` contract in order to retire the specified amount of carbon. The two `view` helper functions `calculateExpectedPoolTokenForETH()` and `calculateExpectedPoolTokenForToken()` can be used to calculate the expected amount of TCO2s that will be offset using functions `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.", "version": 1 }, "storageLayout": { "storage": [ { - "astId": 527, + "astId": 138, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "_initialized", "offset": 0, @@ -996,7 +1183,7 @@ "type": "t_uint8" }, { - "astId": 530, + "astId": 141, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "_initializing", "offset": 1, @@ -1004,7 +1191,7 @@ "type": "t_bool" }, { - "astId": 1344, + "astId": 703, "contract": "contracts/OffsetHelper.sol:OffsetHelper", "label": "__gap", "offset": 0, @@ -1028,35 +1215,59 @@ "type": "t_array(t_uint256)49_storage" }, { - "astId": 5022, + "astId": 3502, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "eligibleTokenAddresses", + "label": "eligibleSwapPaths", "offset": 0, "slot": "101", - "type": "t_mapping(t_string_memory_ptr,t_address)" + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" }, { - "astId": 5025, + "astId": 3507, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "contractRegistryAddress", + "label": "eligibleSwapPathsBySymbol", "offset": 0, "slot": "102", - "type": "t_address" + "type": "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)" }, { - "astId": 5028, + "astId": 3509, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "sushiRouterAddress", + "label": "dexRouterAddress", "offset": 0, "slot": "103", "type": "t_address" }, { - "astId": 5034, + "astId": 3512, "contract": "contracts/OffsetHelper.sol:OffsetHelper", - "label": "balances", + "label": "poolAddresses", "offset": 0, "slot": "104", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 3515, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "tokenSymbolsForPaths", + "offset": 0, + "slot": "105", + "type": "t_array(t_string_storage)dyn_storage" + }, + { + "astId": 3519, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "paths", + "offset": 0, + "slot": "106", + "type": "t_array(t_array(t_address)dyn_storage)dyn_storage" + }, + { + "astId": 3525, + "contract": "contracts/OffsetHelper.sol:OffsetHelper", + "label": "balances", + "offset": 0, + "slot": "107", "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" } ], @@ -1066,6 +1277,24 @@ "label": "address", "numberOfBytes": "20" }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_array(t_address)dyn_storage)dyn_storage": { + "base": "t_array(t_address)dyn_storage", + "encoding": "dynamic_array", + "label": "address[][]", + "numberOfBytes": "32" + }, + "t_array(t_string_storage)dyn_storage": { + "base": "t_string_storage", + "encoding": "dynamic_array", + "label": "string[]", + "numberOfBytes": "32" + }, "t_array(t_uint256)49_storage": { "base": "t_uint256", "encoding": "inplace", @@ -1083,6 +1312,13 @@ "label": "bool", "numberOfBytes": "1" }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + }, "t_mapping(t_address,t_mapping(t_address,t_uint256))": { "encoding": "mapping", "key": "t_address", @@ -1097,18 +1333,23 @@ "numberOfBytes": "32", "value": "t_uint256" }, - "t_mapping(t_string_memory_ptr,t_address)": { + "t_mapping(t_string_memory_ptr,t_array(t_address)dyn_storage)": { "encoding": "mapping", "key": "t_string_memory_ptr", - "label": "mapping(string => address)", + "label": "mapping(string => address[])", "numberOfBytes": "32", - "value": "t_address" + "value": "t_array(t_address)dyn_storage" }, "t_string_memory_ptr": { "encoding": "bytes", "label": "string", "numberOfBytes": "32" }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, "t_uint256": { "encoding": "inplace", "label": "uint256", diff --git a/deployments/polygon/Swapper.json b/deployments/polygon/Swapper.json new file mode 100644 index 0000000..1144cf8 --- /dev/null +++ b/deployments/polygon/Swapper.json @@ -0,0 +1,238 @@ +{ + "address": "0xfca57EE8B62d8e4b9792bd68095c2520723c306d", + "abi": [ + { + "inputs": [ + { + "internalType": "address[][]", + "name": "_paths", + "type": "address[][]" + }, + { + "internalType": "address", + "name": "_swapToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_dexRouterAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "calculateNeededETHAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "dexRouterAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eligibleSwapPaths", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_toToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "swapToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x680cacf777c1fd70e2ccd98299de76304cac15833c23d1e80ce2a5bac7663040", + "receipt": { + "to": null, + "from": "0x101b4C436df747B24D17ce43146Da52fa6006C36", + "contractAddress": "0xfca57EE8B62d8e4b9792bd68095c2520723c306d", + "transactionIndex": 29, + "gasUsed": "1095374", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000800000000000000000000100000000000000000000000000000000000000000000000000000000000080000020000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000800000000000000001000000008000000000000000000010100000000000000000020000000000000000000000000000000000000000000000000000100000", + "blockHash": "0xb832f2a5483d90e4c5030afdcda46c1f58f52a7039ae80647940738ca09fad32", + "transactionHash": "0x680cacf777c1fd70e2ccd98299de76304cac15833c23d1e80ce2a5bac7663040", + "logs": [ + { + "transactionIndex": 29, + "blockNumber": 47456943, + "transactionHash": "0x680cacf777c1fd70e2ccd98299de76304cac15833c23d1e80ce2a5bac7663040", + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x000000000000000000000000101b4c436df747b24d17ce43146da52fa6006c36", + "0x00000000000000000000000067b94473d81d0cd00849d563c94d0432ac988b49" + ], + "data": "0x0000000000000000000000000000000000000000000000000008477c93805cd600000000000000000000000000000000000000000000000113b13cb229b74499000000000000000000000000000000000000000000000fe1b6ece4101aada80900000000000000000000000000000000000000000000000113a8f5359636e7c3000000000000000000000000000000000000000000000fe1b6f52b8cae2e04df", + "logIndex": 125, + "blockHash": "0xb832f2a5483d90e4c5030afdcda46c1f58f52a7039ae80647940738ca09fad32" + } + ], + "blockNumber": 47456943, + "cumulativeGasUsed": "5106795", + "status": 1, + "byzantium": true + }, + "args": [ + [ + [ + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ], + [ + "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ], + [ + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" + ] + ], + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506" + ], + "numDeployments": 1, + "solcInputHash": "10fe5cc2e77ff4188aab80798438e159", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[][]\",\"name\":\"_paths\",\"type\":\"address[][]\"},{\"internalType\":\"address\",\"name\":\"_swapToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_dexRouterAddress\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"calculateNeededETHAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dexRouterAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eligibleSwapPaths\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_toToken\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"swapToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/Swapper.sol\":\"Swapper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@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/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.8.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\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\ninterface IUniswapV2Router01 {\\n function factory() external pure returns (address);\\n function WETH() external pure returns (address);\\n\\n function addLiquidity(\\n address tokenA,\\n address tokenB,\\n uint amountADesired,\\n uint amountBDesired,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB, uint liquidity);\\n function addLiquidityETH(\\n address token,\\n uint amountTokenDesired,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\\n function removeLiquidity(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETH(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountToken, uint amountETH);\\n function removeLiquidityWithPermit(\\n address tokenA,\\n address tokenB,\\n uint liquidity,\\n uint amountAMin,\\n uint amountBMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountA, uint amountB);\\n function removeLiquidityETHWithPermit(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountToken, uint amountETH);\\n function swapExactTokensForTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapTokensForExactTokens(\\n uint amountOut,\\n uint amountInMax,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external returns (uint[] memory amounts);\\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\\n external\\n returns (uint[] memory amounts);\\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\\n external\\n payable\\n returns (uint[] memory amounts);\\n\\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\\n}\\n\",\"keccak256\":\"0x8a3c5c449d4b7cd76513ed6995f4b86e4a86f222c770f8442f5fc128ce29b4d2\"},\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\":{\"content\":\"pragma solidity >=0.6.2;\\n\\nimport './IUniswapV2Router01.sol';\\n\\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\\n function removeLiquidityETHSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline\\n ) external returns (uint amountETH);\\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\\n address token,\\n uint liquidity,\\n uint amountTokenMin,\\n uint amountETHMin,\\n address to,\\n uint deadline,\\n bool approveMax, uint8 v, bytes32 r, bytes32 s\\n ) external returns (uint amountETH);\\n\\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external payable;\\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\\n uint amountIn,\\n uint amountOutMin,\\n address[] calldata path,\\n address to,\\n uint deadline\\n ) external;\\n}\\n\",\"keccak256\":\"0x744e30c133bd0f7ca9e7163433cf6d72f45c6bb1508c2c9c02f1a6db796ae59d\"},\"contracts/test/Swapper.sol\":{\"content\":\"//SPDX-License-Identifier: Unlicense\\npragma solidity ^0.8.0;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\\\";\\n\\ncontract Swapper {\\n using SafeERC20 for IERC20;\\n\\n mapping(address => address[]) public eligibleSwapPaths;\\n address public swapToken;\\n address public dexRouterAddress;\\n\\n constructor(\\n address[][] memory _paths,\\n address _swapToken,\\n address _dexRouterAddress\\n ) {\\n dexRouterAddress = _dexRouterAddress;\\n swapToken = _swapToken;\\n uint256 i = 0;\\n uint256 eligibleSwapPathsLen = _paths.length;\\n while (i < eligibleSwapPathsLen) {\\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\\n i += 1;\\n }\\n }\\n\\n function calculateNeededETHAmount(\\n address _toToken,\\n uint256 _amount\\n ) public view returns (uint256) {\\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\\n\\n address[] memory path = generatePath(swapToken, _toToken);\\n uint256 len = path.length;\\n\\n uint256[] memory amounts = dexRouter.getAmountsIn(_amount, path);\\n // sanity check arrays\\n require(len == amounts.length, \\\"Arrays unequal\\\");\\n require(_amount == amounts[len - 1], \\\"Output amount mismatch\\\");\\n return amounts[0];\\n }\\n\\n function swap(address _toToken, uint256 _amount) public payable {\\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\\n\\n address[] memory path = generatePath(swapToken, _toToken);\\n\\n uint256[] memory amounts = dexRouter.swapETHForExactTokens{\\n value: msg.value\\n }(_amount, path, address(this), block.timestamp);\\n\\n IERC20(_toToken).transfer(msg.sender, _amount);\\n\\n if (msg.value > amounts[0]) {\\n uint256 leftoverETH = msg.value - amounts[0];\\n (bool success, ) = msg.sender.call{value: leftoverETH}(\\n new bytes(0)\\n );\\n\\n require(success, \\\"Failed to send surplus ETH back to user.\\\");\\n }\\n }\\n\\n function generatePath(\\n address _fromToken,\\n address _toToken\\n ) internal view returns (address[] memory path) {\\n uint256 len = eligibleSwapPaths[_fromToken].length;\\n if (len == 1 || eligibleSwapPaths[_fromToken][1] == _toToken) {\\n path = new address[](2);\\n path[0] = _fromToken;\\n path[1] = _toToken;\\n return path;\\n }\\n if (len == 2 || eligibleSwapPaths[_fromToken][2] == _toToken) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = _toToken;\\n return path;\\n }\\n if (len == 3 || eligibleSwapPaths[_fromToken][3] == _toToken) {\\n path = new address[](3);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = _toToken;\\n return path;\\n } else {\\n path = new address[](4);\\n path[0] = _fromToken;\\n path[1] = eligibleSwapPaths[_fromToken][1];\\n path[2] = eligibleSwapPaths[_fromToken][2];\\n path[3] = eligibleSwapPaths[_fromToken][3];\\n path[4] = _toToken;\\n return path;\\n }\\n }\\n\\n fallback() external payable {}\\n\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0x1c94d4fbe790309896da85bc2ecf6b8758d2c3f02d3ab78d156b24ca047e0987\",\"license\":\"Unlicense\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001255380380620012558339810160408190526200003491620001e5565b600280546001600160a01b038084166001600160a01b031992831617909255600180549285169290911691909117905582516000905b808210156200013c578482815181106200009457634e487b7160e01b600052603260045260246000fd5b6020026020010151600080878581518110620000c057634e487b7160e01b600052603260045260246000fd5b6020026020010151600081518110620000e957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002090805190602001906200012692919062000147565b50620001346001836200039b565b91506200006a565b5050505050620003d6565b8280548282559060005260206000209081019282156200019f579160200282015b828111156200019f57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000168565b50620001ad929150620001b1565b5090565b5b80821115620001ad5760008155600101620001b2565b80516001600160a01b0381168114620001e057600080fd5b919050565b600080600060608486031215620001fa578283fd5b83516001600160401b0381111562000210578384fd5b8401601f8101861362000221578384fd5b805162000238620002328262000375565b62000342565b80828252602082019150602084018960208560051b87010111156200025b578788fd5b875b84811015620003125781516001600160401b038111156200027c57898afd5b8b603f82890101126200028d57898afd5b60208188010151620002a3620002328262000375565b808282526020820191506040848b01018f60408560051b878e0101011115620002ca578d8efd5b8d94505b83851015620002f857620002e281620001c8565b83526001949094019360209283019201620002ce565b50875250506020948501949290920191506001016200025d565b5050809650505050506200032960208501620001c8565b91506200033960408501620001c8565b90509250925092565b604051601f8201601f191681016001600160401b03811182821017156200036d576200036d620003c0565b604052919050565b60006001600160401b03821115620003915762000391620003c0565b5060051b60200190565b60008219821115620003bb57634e487b7160e01b81526011600452602481fd5b500190565b634e487b7160e01b600052604160045260246000fd5b610e6f80620003e66000396000f3fe60806040526004361061004b5760003560e01c80631109ec99146100545780631357b11314610087578063d004f0f7146100bf578063dc73e49c146100d2578063e7f67fb1146100f257005b3661005257005b005b34801561006057600080fd5b5061007461006f366004610c11565b610112565b6040519081526020015b60405180910390f35b34801561009357600080fd5b506100a76100a2366004610c11565b6102b6565b6040516001600160a01b03909116815260200161007e565b6100526100cd366004610c11565b6102ee565b3480156100de57600080fd5b506001546100a7906001600160a01b031681565b3480156100fe57600080fd5b506002546100a7906001600160a01b031681565b6002546001546000916001600160a01b03908116918391610134911686610554565b80516040516307c0329d60e21b8152919250906000906001600160a01b03851690631f00ca749061016b9089908790600401610daa565b60006040518083038186803b15801561018357600080fd5b505afa158015610197573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101bf9190810190610c47565b9050805182146102075760405162461bcd60e51b815260206004820152600e60248201526d105c9c985e5cc81d5b995c5d585b60921b60448201526064015b60405180910390fd5b80610213600184610e00565b8151811061023157634e487b7160e01b600052603260045260246000fd5b602002602001015186146102805760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b60448201526064016101fe565b806000815181106102a157634e487b7160e01b600052603260045260246000fd5b60200260200101519450505050505b92915050565b600060205281600052604060002081815481106102d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546001546001600160a01b039182169160009161030e911685610554565b90506000826001600160a01b031663fb3bdb4134868530426040518663ffffffff1660e01b81526004016103459493929190610dcb565b6000604051808303818588803b15801561035e57600080fd5b505af1158015610372573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261039b9190810190610c47565b60405163a9059cbb60e01b8152336004820152602481018690529091506001600160a01b0386169063a9059cbb90604401602060405180830381600087803b1580156103e657600080fd5b505af11580156103fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e9190610d07565b508060008151811061044057634e487b7160e01b600052603260045260246000fd5b602002602001015134111561054d5760008160008151811061047257634e487b7160e01b600052603260045260246000fd5b6020026020010151346104859190610e00565b6040805160008082526020820192839052929350339184916104a691610d71565b60006040518083038185875af1925050503d80600081146104e3576040519150601f19603f3d011682016040523d82523d6000602084013e6104e8565b606091505b505090508061054a5760405162461bcd60e51b815260206004820152602860248201527f4661696c656420746f2073656e6420737572706c757320455448206261636b206044820152673a37903ab9b2b91760c11b60648201526084016101fe565b50505b5050505050565b6001600160a01b03821660009081526020819052604090205460609060018114806105cf57506001600160a01b03848116600090815260208190526040902080549185169160019081106105b857634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b1561067e576040805160028082526060820183529091602083019080368337019050509150838260008151811061061657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061065857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050506102b0565b80600214806106dd57506001600160a01b03848116600090815260208190526040902080549185169160029081106106c657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156107f157604080516003808252608082019092529060208201606080368337019050509150838260008151811061072557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600190811061077057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106107af57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061065857634e487b7160e01b600052603260045260246000fd5b806003148061085057506001600160a01b038481166000908152602081905260409020805491851691600390811061083957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156109ee57604080516003808252608082019092529060208201606080368337019050509150838260008151811061089857634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081529081905260409020805460019081106108e357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061092257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600290811061096d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106109ac57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061065857634e487b7160e01b600052603260045260246000fd5b60408051600480825260a0820190925290602082016080803683370190505091508382600081518110610a3157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546001908110610a7c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600181518110610abb57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546002908110610b0657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600281518110610b4557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546003908110610b9057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600381518110610bcf57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061065857634e487b7160e01b600052603260045260246000fd5b60008060408385031215610c23578182fd5b82356001600160a01b0381168114610c39578283fd5b946020939093013593505050565b60006020808385031215610c59578182fd5b825167ffffffffffffffff80821115610c70578384fd5b818501915085601f830112610c83578384fd5b815181811115610c9557610c95610e23565b8060051b604051601f19603f83011681018181108582111715610cba57610cba610e23565b604052828152858101935084860182860187018a1015610cd8578788fd5b8795505b83861015610cfa578051855260019590950194938601938601610cdc565b5098975050505050505050565b600060208284031215610d18578081fd5b81518015158114610d27578182fd5b9392505050565b6000815180845260208085019450808401835b83811015610d665781516001600160a01b031687529582019590820190600101610d41565b509495945050505050565b60008251815b81811015610d915760208186018101518583015201610d77565b81811115610d9f5782828501525b509190910192915050565b828152604060208201526000610dc36040830184610d2e565b949350505050565b848152608060208201526000610de46080830186610d2e565b6001600160a01b03949094166040830152506060015292915050565b600082821015610e1e57634e487b7160e01b81526011600452602481fd5b500390565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220fc2f138f7a83ba4ce4fd2105384e2316195b1f1ac4e2d922f02f23d19970aa9c64736f6c63430008040033", + "deployedBytecode": "0x60806040526004361061004b5760003560e01c80631109ec99146100545780631357b11314610087578063d004f0f7146100bf578063dc73e49c146100d2578063e7f67fb1146100f257005b3661005257005b005b34801561006057600080fd5b5061007461006f366004610c11565b610112565b6040519081526020015b60405180910390f35b34801561009357600080fd5b506100a76100a2366004610c11565b6102b6565b6040516001600160a01b03909116815260200161007e565b6100526100cd366004610c11565b6102ee565b3480156100de57600080fd5b506001546100a7906001600160a01b031681565b3480156100fe57600080fd5b506002546100a7906001600160a01b031681565b6002546001546000916001600160a01b03908116918391610134911686610554565b80516040516307c0329d60e21b8152919250906000906001600160a01b03851690631f00ca749061016b9089908790600401610daa565b60006040518083038186803b15801561018357600080fd5b505afa158015610197573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101bf9190810190610c47565b9050805182146102075760405162461bcd60e51b815260206004820152600e60248201526d105c9c985e5cc81d5b995c5d585b60921b60448201526064015b60405180910390fd5b80610213600184610e00565b8151811061023157634e487b7160e01b600052603260045260246000fd5b602002602001015186146102805760405162461bcd60e51b815260206004820152601660248201527509eeae8e0eae840c2dadeeadce840dad2e6dac2e8c6d60531b60448201526064016101fe565b806000815181106102a157634e487b7160e01b600052603260045260246000fd5b60200260200101519450505050505b92915050565b600060205281600052604060002081815481106102d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b6002546001546001600160a01b039182169160009161030e911685610554565b90506000826001600160a01b031663fb3bdb4134868530426040518663ffffffff1660e01b81526004016103459493929190610dcb565b6000604051808303818588803b15801561035e57600080fd5b505af1158015610372573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261039b9190810190610c47565b60405163a9059cbb60e01b8152336004820152602481018690529091506001600160a01b0386169063a9059cbb90604401602060405180830381600087803b1580156103e657600080fd5b505af11580156103fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041e9190610d07565b508060008151811061044057634e487b7160e01b600052603260045260246000fd5b602002602001015134111561054d5760008160008151811061047257634e487b7160e01b600052603260045260246000fd5b6020026020010151346104859190610e00565b6040805160008082526020820192839052929350339184916104a691610d71565b60006040518083038185875af1925050503d80600081146104e3576040519150601f19603f3d011682016040523d82523d6000602084013e6104e8565b606091505b505090508061054a5760405162461bcd60e51b815260206004820152602860248201527f4661696c656420746f2073656e6420737572706c757320455448206261636b206044820152673a37903ab9b2b91760c11b60648201526084016101fe565b50505b5050505050565b6001600160a01b03821660009081526020819052604090205460609060018114806105cf57506001600160a01b03848116600090815260208190526040902080549185169160019081106105b857634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b1561067e576040805160028082526060820183529091602083019080368337019050509150838260008151811061061657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260018151811061065857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050506102b0565b80600214806106dd57506001600160a01b03848116600090815260208190526040902080549185169160029081106106c657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156107f157604080516003808252608082019092529060208201606080368337019050509150838260008151811061072557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600190811061077057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826001815181106107af57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260028151811061065857634e487b7160e01b600052603260045260246000fd5b806003148061085057506001600160a01b038481166000908152602081905260409020805491851691600390811061083957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b156109ee57604080516003808252608082019092529060208201606080368337019050509150838260008151811061089857634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920181019190915290851660009081529081905260409020805460019081106108e357634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b03168260018151811061092257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152908516600090815290819052604090208054600290811061096d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316826002815181106109ac57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260038151811061065857634e487b7160e01b600052603260045260246000fd5b60408051600480825260a0820190925290602082016080803683370190505091508382600081518110610a3157634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546001908110610a7c57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600181518110610abb57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546002908110610b0657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600281518110610b4557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092018101919091529085166000908152908190526040902080546003908110610b9057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031682600381518110610bcf57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050828260048151811061065857634e487b7160e01b600052603260045260246000fd5b60008060408385031215610c23578182fd5b82356001600160a01b0381168114610c39578283fd5b946020939093013593505050565b60006020808385031215610c59578182fd5b825167ffffffffffffffff80821115610c70578384fd5b818501915085601f830112610c83578384fd5b815181811115610c9557610c95610e23565b8060051b604051601f19603f83011681018181108582111715610cba57610cba610e23565b604052828152858101935084860182860187018a1015610cd8578788fd5b8795505b83861015610cfa578051855260019590950194938601938601610cdc565b5098975050505050505050565b600060208284031215610d18578081fd5b81518015158114610d27578182fd5b9392505050565b6000815180845260208085019450808401835b83811015610d665781516001600160a01b031687529582019590820190600101610d41565b509495945050505050565b60008251815b81811015610d915760208186018101518583015201610d77565b81811115610d9f5782828501525b509190910192915050565b828152604060208201526000610dc36040830184610d2e565b949350505050565b848152608060208201526000610de46080830186610d2e565b6001600160a01b03949094166040830152506060015292915050565b600082821015610e1e57634e487b7160e01b81526011600452602481fd5b500390565b634e487b7160e01b600052604160045260246000fdfea2646970667358221220fc2f138f7a83ba4ce4fd2105384e2316195b1f1ac4e2d922f02f23d19970aa9c64736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 1133, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "eligibleSwapPaths", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_array(t_address)dyn_storage)" + }, + { + "astId": 1135, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "swapToken", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 1137, + "contract": "contracts/test/Swapper.sol:Swapper", + "label": "dexRouterAddress", + "offset": 0, + "slot": "2", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_array(t_address)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address[])", + "numberOfBytes": "32", + "value": "t_array(t_address)dyn_storage" + } + } + } +} \ No newline at end of file diff --git a/deployments/polygon/solcInputs/10fe5cc2e77ff4188aab80798438e159.json b/deployments/polygon/solcInputs/10fe5cc2e77ff4188aab80798438e159.json new file mode 100644 index 0000000..81a063a --- /dev/null +++ b/deployments/polygon/solcInputs/10fe5cc2e77ff4188aab80798438e159.json @@ -0,0 +1,53 @@ +{ + "language": "Solidity", + "sources": { + "@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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/test/Swapper.sol": { + "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\n\ncontract Swapper {\n using SafeERC20 for IERC20;\n\n mapping(address => address[]) public eligibleSwapPaths;\n address public swapToken;\n address public dexRouterAddress;\n\n constructor(\n address[][] memory _paths,\n address _swapToken,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n swapToken = _swapToken;\n uint256 i = 0;\n uint256 eligibleSwapPathsLen = _paths.length;\n while (i < eligibleSwapPathsLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n i += 1;\n }\n }\n\n function calculateNeededETHAmount(\n address _toToken,\n uint256 _amount\n ) public view returns (uint256) {\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\n\n address[] memory path = generatePath(swapToken, _toToken);\n uint256 len = path.length;\n\n uint256[] memory amounts = dexRouter.getAmountsIn(_amount, path);\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_amount == amounts[len - 1], \"Output amount mismatch\");\n return amounts[0];\n }\n\n function swap(address _toToken, uint256 _amount) public payable {\n IUniswapV2Router02 dexRouter = IUniswapV2Router02(dexRouterAddress);\n\n address[] memory path = generatePath(swapToken, _toToken);\n\n uint256[] memory amounts = dexRouter.swapETHForExactTokens{\n value: msg.value\n }(_amount, path, address(this), block.timestamp);\n\n IERC20(_toToken).transfer(msg.sender, _amount);\n\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus ETH back to user.\");\n }\n }\n\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1 || eligibleSwapPaths[_fromToken][1] == _toToken) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2 || eligibleSwapPaths[_fromToken][2] == _toToken) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3 || eligibleSwapPaths[_fromToken][3] == _toToken) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n fallback() external payable {}\n\n receive() external payable {}\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/polygon/solcInputs/84d45862bdebcae922b40dea008570ca.json b/deployments/polygon/solcInputs/84d45862bdebcae922b40dea008570ca.json deleted file mode 100644 index 45b686d..0000000 --- a/deployments/polygon/solcInputs/84d45862bdebcae922b40dea008570ca.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "language": "Solidity", - "sources": { - "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/interfaces/draft-IERC1822Upgradeable.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 IERC1822ProxiableUpgradeable {\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-upgradeable/proxy/beacon/IBeaconUpgradeable.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 IBeaconUpgradeable {\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-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.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/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.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 ERC1967UpgradeUpgradeable is Initializable {\n function __ERC1967Upgrade_init() internal onlyInitializing {\n }\n\n function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n }\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 StorageSlotUpgradeable.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(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.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 _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 (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822ProxiableUpgradeable(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 StorageSlotUpgradeable.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 StorageSlotUpgradeable.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 StorageSlotUpgradeable.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(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.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 _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\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(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\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/proxy/utils/Initializable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n }\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\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. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeTo(address newImplementation) external virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) 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[50] private __gap;\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/token/ERC721/IERC721Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@openzeppelin/contracts-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/utils/introspection/IERC165Upgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 MathUpgradeable {\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. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n" - }, - "@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.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 StorageSlotUpgradeable {\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-upgradeable/utils/StringsUpgradeable.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = MathUpgradeable.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, MathUpgradeable.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n" - }, - "@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/token/ERC20/utils/SafeERC20.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" - }, - "@openzeppelin/contracts/utils/Address.sol": { - "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" - }, - "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { - "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" - }, - "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { - "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" - }, - "contracts/interfaces/IRetirementCertificates.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\n\nimport \"./IToucanContractRegistry.sol\";\n\ninterface RetirementCertificates is IERC721Upgradeable {\n /// @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n function tokenURI(uint256 tokenId) external returns (string memory);\n\n /// @notice Update retirementMessage, beneficiary, and beneficiaryString of a NFT\n /// within 24h of creation. Empty values are ignored, ie., will not overwrite the\n /// existing stored values in the NFT.\n /// @param tokenId The id of the NFT to update\n /// @param beneficiary The new beneficiary to set in the NFT\n /// @param beneficiaryString The new beneficiaryString to set in the NFT\n /// @param retirementMessage The new retirementMessage to set in the NFT\n /// @dev The function can only be called by a the NFT owner\n function updateCertificate(\n uint256 tokenId,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage\n ) external;\n}\n" - }, - "contracts/interfaces/IToucanCarbonOffsets.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" - }, - "contracts/interfaces/IToucanContractRegistry.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" - }, - "contracts/interfaces/IToucanPoolToken.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" - }, - "contracts/OffsetHelper.sol": { - "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token\n * swap).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token such as BCT or NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using MATIC, specifying the exact amount of TCO2s to retire,\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using MATIC, swapping all sent MATIC into TCO2s,\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _eligibleTokenSymbols A list of token symbols.\n * @param _eligibleTokenAddresses A list of token addresses corresponding\n * to the provided token symbols.\n */\n constructor(\n string[] memory _eligibleTokenSymbols,\n address[] memory _eligibleTokenAddresses\n ) {\n uint256 i = 0;\n uint256 eligibleTokenSymbolsLen = _eligibleTokenSymbols.length;\n while (i < eligibleTokenSymbolsLen) {\n eligibleTokenAddresses[\n _eligibleTokenSymbols[i]\n ] = _eligibleTokenAddresses[i];\n i += 1;\n }\n }\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token such as BCT or NCT.\n *\n * @param who The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, for example, NCT or BCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address who,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Token not swappable\");\n\n _;\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (USDC, WETH, WMATIC). Use `calculateNeededTokenAmount` first in\n * order to find out how much of the ERC20 token is required to retire the\n * specified quantity of TCO2.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _depositedToken The address of the ERC20 token that the user sends\n * (must be one of USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _depositedToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_depositedToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (must be one of USDC, WETH, WMATIC)\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n uint256 _amountToSwap,\n address _poolToken\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(_fromToken, _amountToSwap, _poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending MATIC.\n * Use `calculateNeededETHAmount()` first in order to find out how much\n * MATIC is required to retire the specified quantity of TCO2.\n *\n * This function:\n * 1. Swaps the Matic sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends much MATIC, the leftover amount will be sent back\n * to the user.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(address _poolToken, uint256 _amountToOffset)\n public\n payable\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap MATIC for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending MATIC.\n * All provided MATIC is consumed for offsetting.\n *\n * This function:\n * 1. Swaps the Matic sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(address _poolToken)\n public\n payable\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap MATIC for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, for example, BCT or NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to use, for example, NCT or BCT.\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Checks whether an address can be used by the contract.\n * @param _erc20Address address of the ERC20 token to be checked\n * @return True if the address can be used by the contract\n */\n function isEligible(address _erc20Address) private view returns (bool) {\n bool isToucanContract = IToucanContractRegistry(contractRegistryAddress)\n .checkERC20(_erc20Address);\n if (isToucanContract) return true;\n if (_erc20Address == eligibleTokenAddresses[\"BCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"NCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"USDC\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WETH\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WMATIC\"]) return true;\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n if (_erc20Address == eligibleTokenAddresses[\"USDC\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WETH\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"WMATIC\"]) return true;\n return false;\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n if (_erc20Address == eligibleTokenAddresses[\"BCT\"]) return true;\n if (_erc20Address == eligibleTokenAddresses[\"NCT\"]) return true;\n return false;\n }\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, BCT or NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountsIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _toToken,\n uint256 _toAmount\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n (, uint256[] memory amounts) =\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\n return amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _fromAmount The amount of ERC20 token to swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @return The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken\n ) public view onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n (, uint256[] memory amounts) =\n calculateExactInSwap(_fromToken, _fromAmount, _toToken);\n return amounts[amounts.length - 1];\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The ERC20 oken to deposit and swap\n * @param _toToken The token to swap for (will be held within contract)\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _toToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) {\n // calculate path & amounts\n (address[] memory path, uint256[] memory expAmounts) =\n calculateExactOutSwap(_fromToken, _toToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(sushiRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = routerSushi().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(sushiRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_toToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The ERC20 token to deposit and swap\n * @param _fromAmount The amount of ERC20 token to swap\n * @param _toToken The Toucan token to swap for (will be held within contract)\n * @return Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken\n ) public onlySwappable(_fromToken) onlyRedeemable(_toToken) returns (uint256) {\n // calculate path & amounts\n address[] memory path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(sushiRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = routerSushi().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n uint256 amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_toToken] += amountOut;\n\n return amountOut;\n }\n\n // apparently I need a fallback and a receive method to fix the situation where transfering dust MATIC\n // in the MATIC to token swap fails\n fallback() external payable {}\n\n receive() external payable {}\n\n /**\n * @notice Return how much MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, for example, BCT or NCT.\n *\n * @param _toToken The address of the pool token to swap for, for\n * example, NCT or BCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amounts The amount of MATIC required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(address _toToken, uint256 _toAmount)\n public\n view\n onlyRedeemable(_toToken)\n returns (uint256)\n {\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n (, uint256[] memory amounts) =\n calculateExactOutSwap(fromToken, _toToken, _toAmount);\n return amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of MATIC.\n *\n * @param _fromMaticAmount The amount of MATIC to swap\n * @param _toToken The address of the pool token to swap for,\n * for example, NCT or BCT\n * @return The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n uint256 _fromMaticAmount,\n address _toToken\n ) public view onlyRedeemable(_toToken) returns (uint256) {\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n (, uint256[] memory amounts) =\n calculateExactInSwap(fromToken, _fromMaticAmount, _toToken);\n return amounts[amounts.length - 1];\n }\n\n /**\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining MATIC that was not consumed by the swap is returned.\n * @param _toToken Token to swap for (will be held within contract)\n * @param _toAmount Amount of NCT / BCT wanted\n */\n function swapExactOutETH(address _toToken, uint256 _toAmount) public payable onlyRedeemable(_toToken) {\n // calculate path & amounts\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n address[] memory path = generatePath(fromToken, _toToken);\n\n // swap\n uint256[] memory amounts = routerSushi().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_toToken] += _toAmount;\n }\n\n /**\n * @notice Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided MATIC will be swapped.\n * @param _toToken Token to swap for (will be held within contract)\n * @return Resulting amount of Toucan pool token that got acquired for the\n * swapped MATIC.\n */\n function swapExactInETH(address _toToken) public payable onlyRedeemable(_toToken) returns (uint256) {\n // calculate path & amounts\n uint256 fromAmount = msg.value;\n address fromToken = eligibleTokenAddresses[\"WMATIC\"];\n address[] memory path = generatePath(fromToken, _toToken);\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = routerSushi().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n uint256 amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_toToken] += amountOut;\n\n return amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(address _erc20Addr, uint256 _amount) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT or BCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(address _fromToken, uint256 _amount)\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT or BCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(address[] memory _tco2s, uint256[] memory _amounts)\n public\n {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n function calculateExactOutSwap(\n address _fromToken,\n address _toToken,\n uint256 _toAmount)\n internal view\n returns (address[] memory path, uint256[] memory amounts)\n {\n path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n amounts = routerSushi().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n uint256 _fromAmount,\n address _toToken)\n internal view\n returns (address[] memory path, uint256[] memory amounts)\n {\n path = generatePath(_fromToken, _toToken);\n uint256 len = path.length;\n\n amounts = routerSushi().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n function generatePath(address _fromToken, address _toToken)\n internal\n view\n returns (address[] memory)\n {\n if (_fromToken == eligibleTokenAddresses[\"USDC\"]) {\n address[] memory path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleTokenAddresses[\"USDC\"];\n path[2] = _toToken;\n return path;\n }\n }\n\n function routerSushi() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(sushiRouterAddress);\n }\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible tokens and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _address The address of the token to add\n */\n function setEligibleTokenAddress(\n string memory _tokenSymbol,\n address _address\n ) public virtual onlyOwner {\n eligibleTokenAddresses[_tokenSymbol] = _address;\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the token to remove\n */\n function deleteEligibleTokenAddress(string memory _tokenSymbol)\n public\n virtual\n onlyOwner\n {\n delete eligibleTokenAddresses[_tokenSymbol];\n }\n\n /**\n * @notice Change the TCO2 contracts registry.\n * @param _address The address of the Toucan contract registry to use\n */\n function setToucanContractRegistry(address _address)\n public\n virtual\n onlyOwner\n {\n contractRegistryAddress = _address;\n }\n}\n" - }, - "contracts/OffsetHelperStorage.sol": { - "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(string => address) public eligibleTokenAddresses;\n address public contractRegistryAddress =\n 0x263fA1c180889b3a3f46330F32a4a23287E99FC9;\n address public sushiRouterAddress =\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" - }, - "contracts/test/IWETH.sol": { - "content": "// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWETH is IERC20 {\n function deposit() external payable;\n function withdraw(uint256) external;\n}\n" - }, - "contracts/test/Swapper.sol": { - "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\n\ncontract Swapper {\n using SafeERC20 for IERC20;\n\n address public sushiRouterAddress =\n 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506;\n mapping(string => address) public tokenAddresses;\n\n constructor(string[] memory _tokenSymbols, address[] memory _tokenAddresses)\n {\n uint256 i = 0;\n while (i < _tokenSymbols.length) {\n tokenAddresses[_tokenSymbols[i]] = _tokenAddresses[i];\n i += 1;\n }\n }\n\n function calculateNeededETHAmount(address _toToken, uint256 _amount)\n public\n view\n returns (uint256)\n {\n IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress);\n\n address[] memory path = generatePath(\n tokenAddresses[\"WMATIC\"],\n _toToken\n );\n\n uint256[] memory amounts = routerSushi.getAmountsIn(_amount, path);\n return amounts[0];\n }\n\n function swap(address _toToken, uint256 _amount) public payable {\n IUniswapV2Router02 routerSushi = IUniswapV2Router02(sushiRouterAddress);\n\n address[] memory path = generatePath(\n tokenAddresses[\"WMATIC\"],\n _toToken\n );\n\n uint256[] memory amounts = routerSushi.swapETHForExactTokens{\n value: msg.value\n }(_amount, path, address(this), block.timestamp);\n\n IERC20(_toToken).transfer(msg.sender, _amount);\n\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus ETH back to user.\");\n }\n }\n\n function generatePath(address _fromToken, address _toToken)\n internal\n view\n returns (address[] memory)\n {\n if (_toToken == tokenAddresses[\"USDC\"]) {\n address[] memory path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n } else {\n address[] memory path = new address[](3);\n path[0] = _fromToken;\n path[1] = tokenAddresses[\"USDC\"];\n path[2] = _toToken;\n return path;\n }\n }\n\n fallback() external payable {}\n\n receive() external payable {}\n}\n" - }, - "contracts/types/CarbonProjectTypes.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" - }, - "contracts/types/CarbonProjectVintageTypes.sol": { - "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" - } - }, - "settings": { - "optimizer": { - "enabled": true, - "runs": 200 - }, - "outputSelection": { - "*": { - "*": [ - "abi", - "evm.bytecode", - "evm.deployedBytecode", - "evm.methodIdentifiers", - "metadata", - "devdoc", - "userdoc", - "storageLayout", - "evm.gasEstimates" - ], - "": [ - "ast" - ] - } - }, - "metadata": { - "useLiteralContent": true - } - } -} \ No newline at end of file diff --git a/deployments/polygon/solcInputs/9768af37541e90e4200434e6de116099.json b/deployments/polygon/solcInputs/9768af37541e90e4200434e6de116099.json new file mode 100644 index 0000000..0e855da --- /dev/null +++ b/deployments/polygon/solcInputs/9768af37541e90e4200434e6de116099.json @@ -0,0 +1,89 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.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/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\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/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\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 * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\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 * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\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 * Emits an {Initialized} event the first time it is successfully executed.\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 /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\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/AddressUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@openzeppelin/contracts-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/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/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": { + "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n" + }, + "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": { + "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanCarbonOffsets.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\nimport \"../types/CarbonProjectTypes.sol\";\nimport \"../types/CarbonProjectVintageTypes.sol\";\n\ninterface IToucanCarbonOffsets is IERC20Upgradeable, IERC721Receiver {\n function getGlobalProjectVintageIdentifiers()\n external\n view\n returns (string memory, string memory);\n\n function getAttributes()\n external\n view\n returns (ProjectData memory, VintageData memory);\n\n function getRemaining() external view returns (uint256 remaining);\n\n function getDepositCap() external view returns (uint256);\n\n function retire(uint256 amount) external;\n\n function retireFrom(address account, uint256 amount) external;\n\n function mintCertificateLegacy(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n\n function retireAndMintCertificate(\n string calldata retiringEntityString,\n address beneficiary,\n string calldata beneficiaryString,\n string calldata retirementMessage,\n uint256 amount\n ) external;\n}\n" + }, + "contracts/interfaces/IToucanContractRegistry.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\ninterface IToucanContractRegistry {\n function carbonOffsetBatchesAddress() external view returns (address);\n\n function carbonProjectsAddress() external view returns (address);\n\n function carbonProjectVintagesAddress() external view returns (address);\n\n function toucanCarbonOffsetsFactoryAddress()\n external\n view\n returns (address);\n\n function carbonOffsetBadgesAddress() external view returns (address);\n\n function checkERC20(address _address) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IToucanPoolToken.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IToucanPoolToken is IERC20Upgradeable {\n function deposit(address erc20Addr, uint256 amount) external;\n\n function checkEligible(address erc20Addr) external view returns (bool);\n\n function checkAttributeMatching(address erc20Addr)\n external\n view\n returns (bool);\n\n function calculateRedeemFees(\n address[] memory tco2s,\n uint256[] memory amounts\n ) external view returns (uint256);\n\n function redeemMany(address[] memory tco2s, uint256[] memory amounts)\n external;\n\n function redeemAuto(uint256 amount) external;\n\n function redeemAuto2(uint256 amount)\n external\n returns (address[] memory tco2s, uint256[] memory amounts);\n\n function getRemaining() external view returns (uint256);\n\n function getScoredTCO2s() external view returns (address[] memory);\n}\n" + }, + "contracts/OffsetHelper.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\nimport \"./OffsetHelperStorage.sol\";\nimport \"./interfaces/IToucanPoolToken.sol\";\nimport \"./interfaces/IToucanCarbonOffsets.sol\";\nimport \"./interfaces/IToucanContractRegistry.sol\";\n\n/**\n * @title Toucan Protocol Offset Helpers\n * @notice Helper functions that simplify the carbon offsetting (retirement)\n * process.\n *\n * Retiring carbon tokens requires multiple steps and interactions with\n * Toucan Protocol's main contracts:\n * 1. Obtain a Toucan pool token e.g., NCT (by performing a token\n * swap on a DEX).\n * 2. Redeem the pool token for a TCO2 token.\n * 3. Retire the TCO2 token.\n *\n * These steps are combined in each of the following \"auto offset\" methods\n * implemented in `OffsetHelper` to allow a retirement within one transaction:\n * - `autoOffsetPoolToken()` if the user already owns a Toucan pool\n * token e.g., NCT,\n * - `autoOffsetExactOutETH()` if the user would like to perform a retirement\n * using native tokens e.g., MATIC, specifying the exact amount of TCO2s to retire (only on Polygon, not on Celo),\n * - `autoOffsetExactInETH()` if the user would like to perform a retirement\n * using native tokens, swapping all sent native tokens into TCO2s (only on Polygon, not on Celo),\n * - `autoOffsetExactOutToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of TCO2s to retire,\n * - `autoOffsetExactInToken()` if the user would like to perform a retirement\n * using an ERC20 token (cUSD, USDC, WETH or WMATIC), specifying the exact amount\n * of token to swap into TCO2s.\n *\n * In these methods, \"auto\" refers to the fact that these methods use\n * `autoRedeem()` in order to automatically choose a TCO2 token corresponding\n * to the oldest tokenized carbon project in the specfified token pool.\n * There are no fees incurred by the user when using `autoRedeem()`, i.e., the\n * user receives 1 TCO2 token for each pool token (BCT/NCT) redeemed.\n *\n * There are two `view` helper functions `calculateNeededETHAmount()` and\n * `calculateNeededTokenAmount()` that should be called before using\n * `autoOffsetExactOutETH()` and `autoOffsetExactOutToken()`, to determine how\n * much native tokens e.g., MATIC, respectively how much of the ERC20 token must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * The two `view` helper functions `calculateExpectedPoolTokenForETH()` and\n * `calculateExpectedPoolTokenForToken()` can be used to calculate the\n * expected amount of TCO2s that will be offset using functions\n * `autoOffsetExactInETH()` and `autoOffsetExactInToken()`.\n */\ncontract OffsetHelper is OffsetHelperStorage {\n using SafeERC20 for IERC20;\n // Chain ID of Celo mainnet\n uint256 private constant CELO_MAINNET_CHAINID = 42220;\n\n /**\n * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan\n * pool token e.g., NCT.\n *\n * @param sender The sender of the transaction\n * @param poolToken The address of the Toucan pool token used in the\n * redemption, e.g., NCT\n * @param tco2s An array of the TCO2 addresses that were redeemed\n * @param amounts An array of the amounts of each TCO2 that were redeemed\n */\n event Redeemed(\n address sender,\n address poolToken,\n address[] tco2s,\n uint256[] amounts\n );\n\n modifier onlyRedeemable(address _token) {\n require(isRedeemable(_token), \"Token not redeemable\");\n\n _;\n }\n\n modifier onlySwappable(address _token) {\n require(isSwappable(_token), \"Path doesn't yet exists.\");\n\n _;\n }\n\n modifier nativeTokenChain() {\n require(\n block.chainid != CELO_MAINNET_CHAINID,\n \"The function is not available on this network.\"\n );\n\n _;\n }\n\n /**\n * @notice Contract constructor. Should specify arrays of ERC20 symbols and\n * addresses that can used by the contract.\n *\n * @dev See `isEligible()` for a list of tokens that can be used in the\n * contract. These can be modified after deployment by the contract owner\n * using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`.\n *\n * @param _poolAddresses A list of pool token addresses.\n * @param _tokenSymbolsForPaths An array of symbols of the token the user want to retire carbon credits for\n * @param _paths An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token\n * to the provided token symbols.\n */\n constructor(\n address[] memory _poolAddresses,\n string[] memory _tokenSymbolsForPaths,\n address[][] memory _paths,\n address _dexRouterAddress\n ) {\n dexRouterAddress = _dexRouterAddress;\n poolAddresses = _poolAddresses;\n tokenSymbolsForPaths = _tokenSymbolsForPaths;\n paths = _paths;\n\n uint256 i = 0;\n uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length;\n while (i < eligibleSwapPathsBySymbolLen) {\n eligibleSwapPaths[_paths[i][0]] = _paths[i];\n eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i];\n i += 1;\n }\n }\n\n // fallback payable and receive method to fix the situation where transfering dust native tokens\n // in the native tokens to token swap fails\n\n receive() external payable {}\n\n fallback() external payable {}\n\n // ----------------------------------------\n // Upgradable related functions\n // ----------------------------------------\n\n function initialize() external virtual initializer {\n __Ownable_init_unchained();\n }\n\n // ----------------------------------------\n // Public functions\n // ----------------------------------------\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). The `view` helper function\n * `calculateNeededTokenAmount()` should be called before using `autoOffsetExactOutToken()`,\n * to determine how much native tokens e.g., MATIC must be sent to the\n * `OffsetHelper` contract in order to retire the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the Toucan pool token that the\n * user wants to offset, e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n swapExactOutToken(_fromToken, _poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending ERC20\n * tokens (cUSD, USDC, WETH, WMATIC). All provided token is consumed for\n * offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForToken()`\n * can be used to calculate the expected amount of TCO2s that will be\n * offset using `autoOffsetExactInToken()`.\n *\n * This function:\n * 1. Swaps the ERC20 token sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * Note: The client must approve the ERC20 token that is sent to the contract.\n *\n * @dev When automatically redeeming pool tokens for the lowest quality\n * TCO2s there are no fees and you receive exactly 1 TCO2 token for 1 pool\n * token.\n *\n * @param _fromToken The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToSwap The amount of ERC20 token to swap into Toucan pool\n * token. Full amount will be used for offsetting.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _amountToSwap\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // swap input token for BCT / NCT\n uint256 amountToOffset = swapExactInToken(\n _fromToken,\n _poolToken,\n _amountToSwap\n );\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n *\n * The `view` helper function `calculateNeededETHAmount()` should be called before using\n * `autoOffsetExactOutETH()`, to determine how much native tokens e.g.,\n * MATIC must be sent to the `OffsetHelper` contract in order to retire\n * the specified amount of carbon.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev If the user sends too much native tokens , the leftover amount will be sent back\n * to the user. This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactOutETH(\n address _poolToken,\n uint256 _amountToOffset\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n swapExactOutETH(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available from the specified Toucan token pool by sending native tokens e.g., MATIC.\n * All provided native tokens is consumed for offsetting.\n *\n * The `view` helper function `calculateExpectedPoolTokenForETH()` can be\n * used to calculate the expected amount of TCO2s that will be offset\n * using `autoOffsetExactInETH()`.\n *\n * This function:\n * 1. Swaps the native token e.g. MATIC sent to the contract for the specified pool token.\n * 2. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 3. Retires the TCO2 tokens.\n *\n * @dev This function is only available on Polygon, not on Celo.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n // swap native tokens for BCT / NCT\n uint256 amountToOffset = swapExactInETH(_poolToken);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Retire carbon credits using the lowest quality (oldest) TCO2\n * tokens available by sending Toucan pool tokens, e.g., NCT.\n *\n * This function:\n * 1. Redeems the pool token for the poorest quality TCO2 tokens available.\n * 2. Retires the TCO2 tokens.\n *\n * Note: The client must approve the pool token that is sent.\n *\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @param _amountToOffset The amount of TCO2 to offset.\n *\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoOffsetPoolToken(\n address _poolToken,\n uint256 _amountToOffset\n ) public returns (address[] memory tco2s, uint256[] memory amounts) {\n // deposit pool token from user to this contract\n deposit(_poolToken, _amountToOffset);\n\n // redeem BCT / NCT for TCO2s\n (tco2s, amounts) = autoRedeem(_poolToken, _amountToOffset);\n\n // retire the TCO2s to achieve offset\n autoRetire(tco2s, amounts);\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap\n * @dev Needs to be approved on the client side\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutToken(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) public onlySwappable(_fromToken) onlyRedeemable(_poolToken) {\n // calculate path & amounts\n (\n address[] memory path,\n uint256[] memory expAmounts\n ) = calculateExactOutSwap(_fromToken, _poolToken, _toAmount);\n uint256 amountIn = expAmounts[0];\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n amountIn\n );\n\n // approve router\n IERC20(_fromToken).approve(dexRouterAddress, amountIn);\n\n // swap\n uint256[] memory amounts = dexRouter().swapTokensForExactTokens(\n _toAmount,\n amountIn, // max. input amount\n path,\n address(this),\n block.timestamp\n );\n\n // remove remaining approval if less input token was consumed\n if (amounts[0] < amountIn) {\n IERC20(_fromToken).approve(dexRouterAddress, 0);\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on\n * SushiSwap. All provided ERC20 tokens will be swapped.\n * @dev Needs to be approved on the client side.\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped ERC20 tokens.\n */\n function swapExactInToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // calculate path & amounts\n\n address[] memory path = generatePath(_fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // transfer tokens\n IERC20(_fromToken).safeTransferFrom(\n msg.sender,\n address(this),\n _fromAmount\n );\n\n // approve router\n IERC20(_fromToken).safeApprove(dexRouterAddress, _fromAmount);\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactTokensForTokens(\n _fromAmount,\n 0, // min. output amount\n path,\n address(this),\n block.timestamp\n );\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap.\n * Remaining native tokens that was not consumed by the swap is returned.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The required amount of the Toucan pool token (NCT/BCT)\n */\n function swapExactOutETH(\n address _poolToken,\n uint256 _toAmount\n ) public payable nativeTokenChain onlyRedeemable(_poolToken) {\n // create path & amounts\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n // swap\n uint256[] memory amounts = dexRouter().swapETHForExactTokens{\n value: msg.value\n }(_toAmount, path, address(this), block.timestamp);\n\n // send surplus back\n if (msg.value > amounts[0]) {\n uint256 leftoverETH = msg.value - amounts[0];\n (bool success, ) = msg.sender.call{value: leftoverETH}(\n new bytes(0)\n );\n\n require(success, \"Failed to send surplus back\");\n }\n\n // update balances\n balances[msg.sender][_poolToken] += _toAmount;\n }\n\n /**\n * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All\n * provided native tokens will be swapped.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut Resulting amount of Toucan pool token that got acquired for the\n * swapped native tokens .\n */\n function swapExactInETH(\n address _poolToken\n )\n public\n payable\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n // create path & amounts\n uint256 fromAmount = msg.value;\n // wrap the native token\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n address[] memory path = generatePath(fromToken, _poolToken);\n\n uint256 len = path.length;\n\n // swap\n uint256[] memory amounts = dexRouter().swapExactETHForTokens{\n value: fromAmount\n }(0, path, address(this), block.timestamp);\n amountOut = amounts[len - 1];\n\n // update balances\n balances[msg.sender][_poolToken] += amountOut;\n }\n\n /**\n * @notice Allow users to withdraw tokens they have deposited.\n */\n function withdraw(address _erc20Addr, uint256 _amount) public {\n require(\n balances[msg.sender][_erc20Addr] >= _amount,\n \"Insufficient balance\"\n );\n\n IERC20(_erc20Addr).safeTransfer(msg.sender, _amount);\n balances[msg.sender][_erc20Addr] -= _amount;\n }\n\n /**\n * @notice Allow users to deposit BCT / NCT.\n * @dev Needs to be approved\n */\n function deposit(\n address _erc20Addr,\n uint256 _amount\n ) public onlyRedeemable(_erc20Addr) {\n IERC20(_erc20Addr).safeTransferFrom(msg.sender, address(this), _amount);\n balances[msg.sender][_erc20Addr] += _amount;\n }\n\n /**\n * @notice Redeems the specified amount of NCT / BCT for TCO2.\n * @dev Needs to be approved on the client side\n * @param _fromToken Could be the address of NCT\n * @param _amount Amount to redeem\n * @return tco2s An array of the TCO2 addresses that were redeemed\n * @return amounts An array of the amounts of each TCO2 that were redeemed\n */\n function autoRedeem(\n address _fromToken,\n uint256 _amount\n )\n public\n onlyRedeemable(_fromToken)\n returns (address[] memory tco2s, uint256[] memory amounts)\n {\n require(\n balances[msg.sender][_fromToken] >= _amount,\n \"Insufficient NCT/BCT balance\"\n );\n\n // instantiate pool token (NCT)\n IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken);\n\n // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract\n (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount);\n\n // update balances\n balances[msg.sender][_fromToken] -= _amount;\n uint256 tco2sLen = tco2s.length;\n for (uint256 index = 0; index < tco2sLen; index++) {\n balances[msg.sender][tco2s[index]] += amounts[index];\n }\n\n emit Redeemed(msg.sender, _fromToken, tco2s, amounts);\n }\n\n /**\n * @notice Retire the specified TCO2 tokens.\n * @param _tco2s The addresses of the TCO2s to retire\n * @param _amounts The amounts to retire from each of the corresponding\n * TCO2 addresses\n */\n function autoRetire(\n address[] memory _tco2s,\n uint256[] memory _amounts\n ) public {\n uint256 tco2sLen = _tco2s.length;\n require(tco2sLen != 0, \"Array empty\");\n\n require(tco2sLen == _amounts.length, \"Arrays unequal\");\n\n uint256 i = 0;\n while (i < tco2sLen) {\n if (_amounts[i] == 0) {\n unchecked {\n i++;\n }\n continue;\n }\n require(\n balances[msg.sender][_tco2s[i]] >= _amounts[i],\n \"Insufficient TCO2 balance\"\n );\n\n balances[msg.sender][_tco2s[i]] -= _amounts[i];\n\n IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n }\n\n // ----------------------------------------\n // Public view functions\n // ----------------------------------------\n\n /**\n * @notice Return how much of the specified ERC20 token is required in\n * order to swap for the desired amount of a Toucan pool token, for\n * example, e.g., NCT.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of the ERC20 token required in order to\n * swap for the specified amount of the pool token\n */\n function calculateNeededTokenAmount(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n (, uint256[] memory amounts) = calculateExactOutSwap(\n _fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of ERC20 token.\n *\n * @param _fromToken The address of the ERC20 token used for the swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _fromAmount The amount of ERC20 token to swap\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForToken(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n )\n public\n view\n onlySwappable(_fromToken)\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n (, uint256[] memory amounts) = calculateExactInSwap(\n _fromToken,\n _poolToken,\n _fromAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Return how much native tokens e.g, MATIC is required in order to swap for the\n * desired amount of a Toucan pool token, e.g., NCT.\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @param _toAmount The desired amount of pool token to receive\n * @return amountIn The amount of native tokens required in order to swap for\n * the specified amount of the pool token\n */\n function calculateNeededETHAmount(\n address _poolToken,\n uint256 _toAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountIn)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactOutSwap(\n fromToken,\n _poolToken,\n _toAmount\n );\n amountIn = amounts[0];\n }\n\n /**\n * @notice Calculates the expected amount of Toucan Pool token that can be\n * acquired by swapping the provided amount of native tokens e.g., MATIC.\n *\n * @param _fromTokenAmount The amount of native tokens to swap\n * @param _poolToken The address of the pool token to swap for,\n * e.g., NCT\n * @return amountOut The expected amount of Pool token that can be acquired\n */\n function calculateExpectedPoolTokenForETH(\n address _poolToken,\n uint256 _fromTokenAmount\n )\n public\n view\n nativeTokenChain\n onlyRedeemable(_poolToken)\n returns (uint256 amountOut)\n {\n address fromToken = eligibleSwapPathsBySymbol[\"WMATIC\"][0];\n (, uint256[] memory amounts) = calculateExactInSwap(\n fromToken,\n _poolToken,\n _fromTokenAmount\n );\n amountOut = amounts[amounts.length - 1];\n }\n\n /**\n * @notice Checks if Pool Address is eligible for offsetting.\n * @param _poolToken The address of the pool token to offset,\n * e.g., NCT\n * @return _isEligible Returns a bool if the Pool token is eligible for offsetting\n */\n function isPoolAddressEligible(\n address _poolToken\n ) public view returns (bool _isEligible) {\n _isEligible = isRedeemable(_poolToken);\n }\n\n /**\n * @notice Checks if ERC20 Token is eligible for swapping.\n * @param _erc20Address The address of the ERC20 token that the user sends\n * (e.g., cUSD, cUSD, USDC, WETH, WMATIC)\n * @return _path Returns the path of the token to be exchanged\n */\n function isERC20AddressEligible(\n address _erc20Address\n ) public view returns (address[] memory _path) {\n _path = eligibleSwapPaths[_erc20Address];\n }\n\n // ----------------------------------------\n // Internal methods\n // ----------------------------------------\n\n function calculateExactOutSwap(\n address _fromToken,\n address _poolToken,\n uint256 _toAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsIn(_toAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_toAmount == amounts[len - 1], \"Output amount mismatch\");\n }\n\n function calculateExactInSwap(\n address _fromToken,\n address _poolToken,\n uint256 _fromAmount\n ) internal view returns (address[] memory path, uint256[] memory amounts) {\n // create path & calculate amounts\n path = generatePath(_fromToken, _poolToken);\n uint256 len = path.length;\n\n amounts = dexRouter().getAmountsOut(_fromAmount, path);\n\n // sanity check arrays\n require(len == amounts.length, \"Arrays unequal\");\n require(_fromAmount == amounts[0], \"Input amount mismatch\");\n }\n\n /**\n * @notice Show all pool token addresses that can be used to retired.\n * @param _fromToken a list of token symbols that can be retired.\n * @param _toToken a list of token symbols that can be retired.\n */\n function generatePath(\n address _fromToken,\n address _toToken\n ) internal view returns (address[] memory path) {\n uint256 len = eligibleSwapPaths[_fromToken].length;\n if (len == 1) {\n path = new address[](2);\n path[0] = _fromToken;\n path[1] = _toToken;\n return path;\n }\n if (len == 2) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = _toToken;\n return path;\n }\n if (len == 3) {\n path = new address[](3);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = _toToken;\n return path;\n } else {\n path = new address[](4);\n path[0] = _fromToken;\n path[1] = eligibleSwapPaths[_fromToken][1];\n path[2] = eligibleSwapPaths[_fromToken][2];\n path[3] = eligibleSwapPaths[_fromToken][3];\n path[4] = _toToken;\n return path;\n }\n }\n\n function dexRouter() internal view returns (IUniswapV2Router02) {\n return IUniswapV2Router02(dexRouterAddress);\n }\n\n /**\n * @notice Checks whether an address is a Toucan pool token address\n * @param _erc20Address address of token to be checked\n * @return True if the address is a Toucan pool token address\n */\n function isRedeemable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Checks whether an address can be used in a token swap\n * @param _erc20Address address of token to be checked\n * @return True if the specified address can be used in a swap\n */\n function isSwappable(address _erc20Address) private view returns (bool) {\n for (uint i = 0; i < paths.length; i++) {\n if (paths[i][0] == _erc20Address) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * @notice Cheks if Pool Token is eligible for Offsetting.\n * @param _poolToken The addresses of the pool token to redeem\n * @return _isEligible Returns if token can be redeemed\n */\n\n // ----------------------------------------\n // Admin methods\n // ----------------------------------------\n\n /**\n * @notice Change or add eligible paths and their addresses.\n * @param _tokenSymbol The symbol of the token to add\n * @param _path The path of the path to add\n */\n function addPath(\n string memory _tokenSymbol,\n address[] memory _path\n ) public virtual onlyOwner {\n eligibleSwapPaths[_path[0]] = _path;\n eligibleSwapPathsBySymbol[_tokenSymbol] = _path;\n tokenSymbolsForPaths.push(_tokenSymbol);\n }\n\n /**\n * @notice Delete eligible tokens stored in the contract.\n * @param _tokenSymbol The symbol of the path to remove\n */\n function removePath(string memory _tokenSymbol) public virtual onlyOwner {\n delete eligibleSwapPaths[eligibleSwapPathsBySymbol[_tokenSymbol][0]];\n delete eligibleSwapPathsBySymbol[_tokenSymbol];\n }\n\n /**\n * @notice Change or add pool token addresses.\n * @param _poolToken The address of the pool token to add\n */\n function addPoolToken(address _poolToken) public virtual onlyOwner {\n poolAddresses.push(_poolToken);\n }\n\n /**\n * @notice Delete eligible pool token addresses stored in the contract.\n * @param _poolToken The address of the pool token to remove\n */\n function removePoolToken(address _poolToken) public virtual onlyOwner {\n for (uint256 i; i < poolAddresses.length; i++) {\n if (poolAddresses[i] == _poolToken) {\n poolAddresses[i] = poolAddresses[poolAddresses.length - 1];\n poolAddresses.pop();\n break;\n }\n }\n }\n}\n" + }, + "contracts/OffsetHelperStorage.sol": { + "content": "// SPDX-FileCopyrightText: 2022 Toucan Labs\n//\n// SPDX-License-Identifier: GPL-3.0\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OffsetHelperStorage is OwnableUpgradeable {\n // token symbol => token address\n mapping(address => address[]) public eligibleSwapPaths;\n mapping(string => address[]) public eligibleSwapPathsBySymbol;\n\n address public dexRouterAddress;\n\n address[] public poolAddresses;\n string[] public tokenSymbolsForPaths;\n address[][] public paths;\n\n // user => (token => amount)\n mapping(address => mapping(address => uint256)) public balances;\n}\n" + }, + "contracts/types/CarbonProjectTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\n/// @dev CarbonProject related data and attributes\nstruct ProjectData {\n string projectId;\n string standard;\n string methodology;\n string region;\n string storageMethod;\n string method;\n string emissionType;\n string category;\n string uri;\n address controller;\n}\n" + }, + "contracts/types/CarbonProjectVintageTypes.sol": { + "content": "// SPDX-FileCopyrightText: 2021 Toucan Labs\n//\n// SPDX-License-Identifier: UNLICENSED\n\n// If you encounter a vulnerability or an issue, please contact or visit security.toucan.earth\n\npragma solidity >=0.8.4 <0.9.0;\n\nstruct VintageData {\n /// @dev A human-readable string which differentiates this from other vintages in\n /// the same project, and helps build the corresponding TCO2 name and symbol.\n string name;\n uint64 startTime; // UNIX timestamp\n uint64 endTime; // UNIX timestamp\n uint256 projectTokenId;\n uint64 totalVintageQuantity;\n bool isCorsiaCompliant;\n bool isCCPcompliant;\n string coBenefits;\n string correspAdjustment;\n string additionalCertification;\n string uri;\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file From 6f07a6053b8b0fbb7a0d812057c5cf0b11b0d07a Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 12:00:32 +0100 Subject: [PATCH 09/12] refactor: Restructure Contract to follow Solidity Style guide refactor: Restructure Contract to follow Solidity Style guide --- contracts/OffsetHelper.sol | 401 ++++++++++++++++-------------- contracts/OffsetHelperStorage.sol | 3 +- 2 files changed, 211 insertions(+), 193 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 8511a8c..6e451af 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -130,6 +130,12 @@ contract OffsetHelper is OffsetHelperStorage { } } + // The receive and fallback method are needed to fix the situation where transfering dust native tokens + // in the native tokens to token swap fails + receive() external payable {} + + fallback() external payable {} + // ---------------------------------------- // Upgradable related functions // ---------------------------------------- @@ -138,6 +144,10 @@ contract OffsetHelper is OffsetHelperStorage { __Ownable_init_unchained(); } + // ---------------------------------------- + // Public functions + // ---------------------------------------- + /** * @notice Retire carbon credits using the lowest quality (oldest) TCO2 * tokens available from the specified Toucan token pool by sending ERC20 @@ -334,103 +344,80 @@ contract OffsetHelper is OffsetHelperStorage { } /** - * @notice Checks whether an address is a Toucan pool token address - * @param _erc20Address address of token to be checked - * @return True if the address is a Toucan pool token address + * @notice Redeems the specified amount of NCT / BCT for TCO2. + * @dev Needs to be approved on the client side + * @param _fromToken Could be the address of NCT + * @param _amount Amount to redeem + * @return tco2s An array of the TCO2 addresses that were redeemed + * @return amounts An array of the amounts of each TCO2 that were redeemed */ - function isRedeemable(address _erc20Address) private view returns (bool) { - for (uint i = 0; i < poolAddresses.length; i++) { - if (poolAddresses[i] == _erc20Address) { - return true; - } + function autoRedeem( + address _fromToken, + uint256 _amount + ) + public + onlyRedeemable(_fromToken) + returns (address[] memory tco2s, uint256[] memory amounts) + { + require( + balances[msg.sender][_fromToken] >= _amount, + "Insufficient NCT/BCT balance" + ); + + // instantiate pool token (NCT) + IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken); + + // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract + (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount); + + // update balances + balances[msg.sender][_fromToken] -= _amount; + uint256 tco2sLen = tco2s.length; + for (uint256 index = 0; index < tco2sLen; index++) { + balances[msg.sender][tco2s[index]] += amounts[index]; } - return false; + emit Redeemed(msg.sender, _fromToken, tco2s, amounts); } /** - * @notice Checks whether an address can be used in a token swap - * @param _erc20Address address of token to be checked - * @return True if the specified address can be used in a swap + * @notice Retire the specified TCO2 tokens. + * @param _tco2s The addresses of the TCO2s to retire + * @param _amounts The amounts to retire from each of the corresponding + * TCO2 addresses */ - function isSwappable(address _erc20Address) private view returns (bool) { - for (uint i = 0; i < paths.length; i++) { - if (paths[i][0] == _erc20Address) { - return true; + function autoRetire( + address[] memory _tco2s, + uint256[] memory _amounts + ) public { + uint256 tco2sLen = _tco2s.length; + require(tco2sLen != 0, "Array empty"); + + require(tco2sLen == _amounts.length, "Arrays unequal"); + + uint256 i = 0; + while (i < tco2sLen) { + if (_amounts[i] == 0) { + unchecked { + i++; + } + continue; } - } + require( + balances[msg.sender][_tco2s[i]] >= _amounts[i], + "Insufficient TCO2 balance" + ); - return false; - } + balances[msg.sender][_tco2s[i]] -= _amounts[i]; - /** - * @notice Return how much of the specified ERC20 token is required in - * order to swap for the desired amount of a Toucan pool token, for - * example, e.g., NCT. - * - * @param _fromToken The address of the ERC20 token used for the swap - * @param _poolToken The address of the pool token to swap for, - * e.g., NCT - * @param _toAmount The desired amount of pool token to receive - * @return amountIn The amount of the ERC20 token required in order to - * swap for the specified amount of the pool token - */ - function calculateNeededTokenAmount( - address _fromToken, - address _poolToken, - uint256 _toAmount - ) - public - view - onlySwappable(_fromToken) - onlyRedeemable(_poolToken) - returns (uint256 amountIn) - { - (, uint256[] memory amounts) = calculateExactOutSwap( - _fromToken, - _poolToken, - _toAmount - ); - amountIn = amounts[0]; - } + IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]); - /** - * @notice Calculates the expected amount of Toucan Pool token that can be - * acquired by swapping the provided amount of ERC20 token. - * - * @param _fromToken The address of the ERC20 token used for the swap - * @param _poolToken The address of the pool token to swap for, - * e.g., NCT - * @param _fromAmount The amount of ERC20 token to swap - * @return amountOut The expected amount of Pool token that can be acquired - */ - function calculateExpectedPoolTokenForToken( - address _fromToken, - address _poolToken, - uint256 _fromAmount - ) - public - view - onlySwappable(_fromToken) - onlyRedeemable(_poolToken) - returns (uint256 amountOut) - { - (, uint256[] memory amounts) = calculateExactInSwap( - _fromToken, - _poolToken, - _fromAmount - ); - amountOut = amounts[amounts.length - 1]; + unchecked { + ++i; + } + } } - /** - * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap - * @dev Needs to be approved on the client side - * @param _fromToken The address of the ERC20 token used for the swap - * @param _poolToken The address of the pool token to swap for, - * e.g., NCT - * @param _toAmount The required amount of the Toucan pool token (NCT/BCT) - */ function swapExactOutToken( address _fromToken, address _poolToken, @@ -521,54 +508,6 @@ contract OffsetHelper is OffsetHelperStorage { balances[msg.sender][_poolToken] += amountOut; } - // apparently I need a fallback and a receive method to fix the situation where transfering dust native tokens - // in the native tokens to token swap fails - fallback() external payable {} - - /** - * @notice Return how much native tokens e.g, MATIC is required in order to swap for the - * desired amount of a Toucan pool token, e.g., NCT. - * @param _poolToken The address of the pool token to swap for, for - * example, NCT - * @param _toAmount The desired amount of pool token to receive - * @return amountIn The amount of native tokens required in order to swap for - * the specified amount of the pool token - */ - function calculateNeededETHAmount( - address _poolToken, - uint256 _toAmount - ) public view onlyRedeemable(_poolToken) returns (uint256 amountIn) { - address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; - (, uint256[] memory amounts) = calculateExactOutSwap( - fromToken, - _poolToken, - _toAmount - ); - amountIn = amounts[0]; - } - - /** - * @notice Calculates the expected amount of Toucan Pool token that can be - * acquired by swapping the provided amount of native tokens e.g., MATIC. - * - * @param _fromTokenAmount The amount of native tokens to swap - * @param _poolToken The address of the pool token to swap for, - * e.g., NCT - * @return amountOut The expected amount of Pool token that can be acquired - */ - function calculateExpectedPoolTokenForETH( - address _poolToken, - uint256 _fromTokenAmount - ) public view onlyRedeemable(_poolToken) returns (uint256 amountOut) { - address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; - (, uint256[] memory amounts) = calculateExactInSwap( - fromToken, - _poolToken, - _fromTokenAmount - ); - amountOut = amounts[amounts.length - 1]; - } - /** * @notice Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. * Remaining native tokens that was not consumed by the swap is returned. @@ -658,81 +597,127 @@ contract OffsetHelper is OffsetHelperStorage { balances[msg.sender][_erc20Addr] += _amount; } + // ---------------------------------------- + // Public view functions + // ---------------------------------------- + /** - * @notice Redeems the specified amount of NCT / BCT for TCO2. - * @dev Needs to be approved on the client side - * @param _fromToken Could be the address of NCT - * @param _amount Amount to redeem - * @return tco2s An array of the TCO2 addresses that were redeemed - * @return amounts An array of the amounts of each TCO2 that were redeemed + * @notice Return how much of the specified ERC20 token is required in + * order to swap for the desired amount of a Toucan pool token, for + * example, e.g., NCT. + * + * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT + * @param _toAmount The desired amount of pool token to receive + * @return amountIn The amount of the ERC20 token required in order to + * swap for the specified amount of the pool token */ - function autoRedeem( + function calculateNeededTokenAmount( address _fromToken, - uint256 _amount + address _poolToken, + uint256 _toAmount ) public - onlyRedeemable(_fromToken) - returns (address[] memory tco2s, uint256[] memory amounts) + view + onlySwappable(_fromToken) + onlyRedeemable(_poolToken) + returns (uint256 amountIn) { - require( - balances[msg.sender][_fromToken] >= _amount, - "Insufficient NCT/BCT balance" + (, uint256[] memory amounts) = calculateExactOutSwap( + _fromToken, + _poolToken, + _toAmount ); - - // instantiate pool token (NCT) - IToucanPoolToken PoolTokenImplementation = IToucanPoolToken(_fromToken); - - // auto redeem pool token for TCO2; will transfer automatically picked TCO2 to this contract - (tco2s, amounts) = PoolTokenImplementation.redeemAuto2(_amount); - - // update balances - balances[msg.sender][_fromToken] -= _amount; - uint256 tco2sLen = tco2s.length; - for (uint256 index = 0; index < tco2sLen; index++) { - balances[msg.sender][tco2s[index]] += amounts[index]; - } - - emit Redeemed(msg.sender, _fromToken, tco2s, amounts); + amountIn = amounts[0]; } /** - * @notice Retire the specified TCO2 tokens. - * @param _tco2s The addresses of the TCO2s to retire - * @param _amounts The amounts to retire from each of the corresponding - * TCO2 addresses + * @notice Return how much native tokens e.g, MATIC is required in order to swap for the + * desired amount of a Toucan pool token, e.g., NCT. + * @param _poolToken The address of the pool token to swap for, for + * example, NCT + * @param _toAmount The desired amount of pool token to receive + * @return amountIn The amount of native tokens required in order to swap for + * the specified amount of the pool token */ - function autoRetire( - address[] memory _tco2s, - uint256[] memory _amounts - ) public { - uint256 tco2sLen = _tco2s.length; - require(tco2sLen != 0, "Array empty"); - - require(tco2sLen == _amounts.length, "Arrays unequal"); - - uint256 i = 0; - while (i < tco2sLen) { - if (_amounts[i] == 0) { - unchecked { - i++; - } - continue; - } - require( - balances[msg.sender][_tco2s[i]] >= _amounts[i], - "Insufficient TCO2 balance" - ); + function calculateNeededETHAmount( + address _poolToken, + uint256 _toAmount + ) public view onlyRedeemable(_poolToken) returns (uint256 amountIn) { + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + (, uint256[] memory amounts) = calculateExactOutSwap( + fromToken, + _poolToken, + _toAmount + ); + amountIn = amounts[0]; + } - balances[msg.sender][_tco2s[i]] -= _amounts[i]; + /** + * @notice Calculates the expected amount of Toucan Pool token that can be + * acquired by swapping the provided amount of ERC20 token. + * + * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT + * @param _fromAmount The amount of ERC20 token to swap + * @return amountOut The expected amount of Pool token that can be acquired + */ + function calculateExpectedPoolTokenForToken( + address _fromToken, + address _poolToken, + uint256 _fromAmount + ) + public + view + onlySwappable(_fromToken) + onlyRedeemable(_poolToken) + returns (uint256 amountOut) + { + (, uint256[] memory amounts) = calculateExactInSwap( + _fromToken, + _poolToken, + _fromAmount + ); + amountOut = amounts[amounts.length - 1]; + } - IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]); + /** + * @notice Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap + * @dev Needs to be approved on the client side + * @param _fromToken The address of the ERC20 token used for the swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT + * @param _toAmount The required amount of the Toucan pool token (NCT/BCT) + */ - unchecked { - ++i; - } - } + /** + * @notice Calculates the expected amount of Toucan Pool token that can be + * acquired by swapping the provided amount of native tokens e.g., MATIC. + * + * @param _fromTokenAmount The amount of native tokens to swap + * @param _poolToken The address of the pool token to swap for, + * e.g., NCT + * @return amountOut The expected amount of Pool token that can be acquired + */ + function calculateExpectedPoolTokenForETH( + address _poolToken, + uint256 _fromTokenAmount + ) public view onlyRedeemable(_poolToken) returns (uint256 amountOut) { + address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; + (, uint256[] memory amounts) = calculateExactInSwap( + fromToken, + _poolToken, + _fromTokenAmount + ); + amountOut = amounts[amounts.length - 1]; } + // ---------------------------------------- + // Internal functions + // ---------------------------------------- + function calculateExactOutSwap( address _fromToken, address _poolToken, @@ -810,6 +795,40 @@ contract OffsetHelper is OffsetHelperStorage { return IUniswapV2Router02(dexRouterAddress); } + // ---------------------------------------- + // Private functions + // ---------------------------------------- + + /** + * @notice Checks whether an address is a Toucan pool token address + * @param _erc20Address address of token to be checked + * @return True if the address is a Toucan pool token address + */ + function isRedeemable(address _erc20Address) private view returns (bool) { + for (uint i = 0; i < poolAddresses.length; i++) { + if (poolAddresses[i] == _erc20Address) { + return true; + } + } + + return false; + } + + /** + * @notice Checks whether an address can be used in a token swap + * @param _erc20Address address of token to be checked + * @return True if the specified address can be used in a swap + */ + function isSwappable(address _erc20Address) private view returns (bool) { + for (uint i = 0; i < paths.length; i++) { + if (paths[i][0] == _erc20Address) { + return true; + } + } + + return false; + } + // ---------------------------------------- // Admin methods // ---------------------------------------- diff --git a/contracts/OffsetHelperStorage.sol b/contracts/OffsetHelperStorage.sol index d27741a..441e78f 100644 --- a/contracts/OffsetHelperStorage.sol +++ b/contracts/OffsetHelperStorage.sol @@ -11,11 +11,10 @@ contract OffsetHelperStorage is OwnableUpgradeable { mapping(address => address[]) public eligibleSwapPaths; mapping(string => address[]) public eligibleSwapPathsBySymbol; - address public dexRouterAddress; - address[] public poolAddresses; string[] public tokenSymbolsForPaths; address[][] public paths; + address public dexRouterAddress; // user => (token => amount) mapping(address => mapping(address => uint256)) public balances; From b872e983c2ce400897b092d7e95e907c63da2110 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Wed, 13 Sep 2023 12:02:25 +0100 Subject: [PATCH 10/12] docs: create new docs for new OffsetHelper --- docs/OffsetHelper.md | 404 +++++++++++++++++++----------------- docs/OffsetHelperStorage.md | 23 +- 2 files changed, 236 insertions(+), 191 deletions(-) diff --git a/docs/OffsetHelper.md b/docs/OffsetHelper.md index e526311..3c73df8 100644 --- a/docs/OffsetHelper.md +++ b/docs/OffsetHelper.md @@ -7,6 +7,7 @@ process. Retiring carbon tokens requires multiple steps and interactions with Toucan Protocol's main contracts: + 1. Obtain a Toucan pool token such as BCT or NCT (by performing a token swap). 2. Redeem the pool token for a TCO2 token. @@ -14,6 +15,7 @@ Toucan Protocol's main contracts: These steps are combined in each of the following "auto offset" methods implemented in `OffsetHelper` to allow a retirement within one transaction: + - `autoOffsetPoolToken()` if the user already owns a Toucan pool token such as BCT or NCT, - `autoOffsetExactOutETH()` if the user would like to perform a retirement @@ -59,10 +61,10 @@ using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`._ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _eligibleTokenSymbols | string[] | A list of token symbols. | -| _eligibleTokenAddresses | address[] | A list of token addresses corresponding to the provided token symbols. | +| Name | Type | Description | +| ------------------------ | --------- | ---------------------------------------------------------------------- | +| \_eligibleTokenSymbols | string[] | A list of token symbols. | +| \_eligibleTokenAddresses | address[] | A list of token addresses corresponding to the provided token symbols. | ### Redeemed @@ -75,12 +77,12 @@ pool token such as BCT or NCT. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| who | address | The sender of the transaction | -| poolToken | address | The address of the Toucan pool token used in the redemption, for example, NCT or BCT | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | -| amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | +| Name | Type | Description | +| --------- | --------- | ------------------------------------------------------------------------------------ | +| who | address | The sender of the transaction | +| poolToken | address | The address of the Toucan pool token used in the redemption, for example, NCT or BCT | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | ### onlyRedeemable @@ -94,6 +96,52 @@ modifier onlyRedeemable(address _token) modifier onlySwappable(address _token) ``` +### nativeTokenChain + +```solidity +modifier nativeTokenChain() +``` + +### constructor + +```solidity +constructor(address[] _poolAddresses, string[] _tokenSymbolsForPaths, address[][] _paths, address _dexRouterAddress) public +``` + +Contract constructor. Should specify arrays of ERC20 symbols and +addresses that can used by the contract. + +_See `isEligible()` for a list of tokens that can be used in the +contract. These can be modified after deployment by the contract owner +using `setEligibleTokenAddress()` and `deleteEligibleTokenAddress()`._ + +#### Parameters + +| Name | Type | Description | +| ---------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| \_poolAddresses | address[] | A list of pool token addresses. | +| \_tokenSymbolsForPaths | string[] | An array of symbols of the token the user want to retire carbon credits for | +| \_paths | address[][] | An array of arrays of addresses to describe the path needed to swap form the baseToken to the pool Token to the provided token symbols. | +| \_dexRouterAddress | address | | + +### receive + +```solidity +receive() external payable +``` + +### fallback + +```solidity +fallback() external payable +``` + +### initialize + +```solidity +function initialize() external virtual +``` + ### autoOffsetExactOutToken ```solidity @@ -107,6 +155,7 @@ order to find out how much of the ERC20 token is required to retire the specified quantity of TCO2. This function: + 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. @@ -119,17 +168,17 @@ token._ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _depositedToken | address | The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC) | -| _poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT | -| _amountToOffset | uint256 | The amount of TCO2 to offset | +| Name | Type | Description | +| ---------------- | ------- | ---------------------------------------------------------------------------------------- | +| \_depositedToken | address | The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC) | +| \_poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT | +| \_amountToOffset | uint256 | The amount of TCO2 to offset | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | | amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | ### autoOffsetExactInToken @@ -144,6 +193,7 @@ tokens (USDC, WETH, WMATIC). All provided token is consumed for offsetting. This function: + 1. Swaps the ERC20 token sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. @@ -156,17 +206,17 @@ token._ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC) | -| _amountToSwap | uint256 | The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting. | -| _poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT | +| Name | Type | Description | +| -------------- | ------- | -------------------------------------------------------------------------------------------------- | +| \_fromToken | address | The address of the ERC20 token that the user sends (must be one of USDC, WETH, WMATIC) | +| \_amountToSwap | uint256 | The amount of ERC20 token to swap into Toucan pool token. Full amount will be used for offsetting. | +| \_poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | | amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | ### autoOffsetExactOutETH @@ -181,6 +231,7 @@ Use `calculateNeededETHAmount()` first in order to find out how much MATIC is required to retire the specified quantity of TCO2. This function: + 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. @@ -190,16 +241,16 @@ to the user._ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | -| _amountToOffset | uint256 | The amount of TCO2 to offset. | +| Name | Type | Description | +| ---------------- | ------- | ----------------------------------------------------------------------------------------- | +| \_poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | +| \_amountToOffset | uint256 | The amount of TCO2 to offset. | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | | amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | ### autoOffsetExactInETH @@ -213,21 +264,22 @@ tokens available from the specified Toucan token pool by sending MATIC. All provided MATIC is consumed for offsetting. This function: + 1. Swaps the Matic sent to the contract for the specified pool token. 2. Redeems the pool token for the poorest quality TCO2 tokens available. 3. Retires the TCO2 tokens. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | +| Name | Type | Description | +| ----------- | ------- | ----------------------------------------------------------------------------------------- | +| \_poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | | amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | ### autoOffsetPoolToken @@ -240,6 +292,7 @@ Retire carbon credits using the lowest quality (oldest) TCO2 tokens available by sending Toucan pool tokens, for example, BCT or NCT. This function: + 1. Redeems the pool token for the poorest quality TCO2 tokens available. 2. Retires the TCO2 tokens. @@ -247,64 +300,56 @@ Note: The client must approve the pool token that is sent. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | -| _amountToOffset | uint256 | The amount of TCO2 to offset. | +| Name | Type | Description | +| ---------------- | ------- | ----------------------------------------------------------------------------------------- | +| \_poolToken | address | The address of the Toucan pool token that the user wants to use, for example, NCT or BCT. | +| \_amountToOffset | uint256 | The amount of TCO2 to offset. | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | | amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | -### calculateNeededTokenAmount +### autoRedeem ```solidity -function calculateNeededTokenAmount(address _fromToken, address _toToken, uint256 _toAmount) public view returns (uint256) +function autoRedeem(address _fromToken, uint256 _amount) public returns (address[] tco2s, uint256[] amounts) ``` -Return how much of the specified ERC20 token is required in -order to swap for the desired amount of a Toucan pool token, for -example, BCT or NCT. +Redeems the specified amount of NCT / BCT for TCO2. + +_Needs to be approved on the client side_ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | The address of the ERC20 token used for the swap | -| _toToken | address | The address of the pool token to swap for, for example, NCT or BCT | -| _toAmount | uint256 | The desired amount of pool token to receive | +| Name | Type | Description | +| ----------- | ------- | --------------------------- | +| \_fromToken | address | Could be the address of NCT | +| \_amount | uint256 | Amount to redeem | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | amountsIn The amount of the ERC20 token required in order to swap for the specified amount of the pool token | +| Name | Type | Description | +| ------- | --------- | ------------------------------------------------------- | +| tco2s | address[] | An array of the TCO2 addresses that were redeemed | +| amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | -### calculateExpectedPoolTokenForToken +### autoRetire ```solidity -function calculateExpectedPoolTokenForToken(address _fromToken, uint256 _fromAmount, address _toToken) public view returns (uint256) +function autoRetire(address[] _tco2s, uint256[] _amounts) public ``` -Calculates the expected amount of Toucan Pool token that can be -acquired by swapping the provided amount of ERC20 token. +Retire the specified TCO2 tokens. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | The address of the ERC20 token used for the swap | -| _fromAmount | uint256 | The amount of ERC20 token to swap | -| _toToken | address | The address of the pool token to swap for, for example, NCT or BCT | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | The expected amount of Pool token that can be acquired | +| Name | Type | Description | +| --------- | --------- | ------------------------------------------------------------------- | +| \_tco2s | address[] | The addresses of the TCO2s to retire | +| \_amounts | uint256[] | The amounts to retire from each of the corresponding TCO2 addresses | ### swapExactOutToken @@ -312,18 +357,6 @@ acquired by swapping the provided amount of ERC20 token. function swapExactOutToken(address _fromToken, address _toToken, uint256 _toAmount) public ``` -Swap eligible ERC20 tokens for Toucan pool tokens (BCT/NCT) on SushiSwap - -_Needs to be approved on the client side_ - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | The ERC20 oken to deposit and swap | -| _toToken | address | The token to swap for (will be held within contract) | -| _toAmount | uint256 | The required amount of the Toucan pool token (NCT/BCT) | - ### swapExactInToken ```solidity @@ -337,167 +370,163 @@ _Needs to be approved on the client side._ #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | The ERC20 token to deposit and swap | -| _fromAmount | uint256 | The amount of ERC20 token to swap | -| _toToken | address | The Toucan token to swap for (will be held within contract) | +| Name | Type | Description | +| ------------ | ------- | ----------------------------------------------------------- | +| \_fromToken | address | The ERC20 token to deposit and swap | +| \_fromAmount | uint256 | The amount of ERC20 token to swap | +| \_toToken | address | The Toucan token to swap for (will be held within contract) | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens. | +| Name | Type | Description | +| ---- | ------- | ------------------------------------------------------------------------------------- | +| [0] | uint256 | Resulting amount of Toucan pool token that got acquired for the swapped ERC20 tokens. | -### fallback +### swapExactOutETH ```solidity -fallback() external payable +function swapExactOutETH(address _poolToken, uint256 _toAmount) public payable ``` -### receive +Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. +Remaining native tokens that was not consumed by the swap is returned. -```solidity -receive() external payable -``` +#### Parameters -### calculateNeededETHAmount +| Name | Type | Description | +| ----------- | ------- | ------------------------------------------------------ | +| \_poolToken | address | The address of the pool token to swap for, e.g., NCT | +| \_toAmount | uint256 | The required amount of the Toucan pool token (NCT/BCT) | + +### swapExactInETH ```solidity -function calculateNeededETHAmount(address _toToken, uint256 _toAmount) public view returns (uint256) +function swapExactInETH(address _poolToken) public payable returns (uint256 amountOut) ``` -Return how much MATIC is required in order to swap for the -desired amount of a Toucan pool token, for example, BCT or NCT. +Swap native tokens e.g., MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All +provided native tokens will be swapped. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _toToken | address | The address of the pool token to swap for, for example, NCT or BCT | -| _toAmount | uint256 | The desired amount of pool token to receive | +| Name | Type | Description | +| ----------- | ------- | ---------------------------------------------------- | +| \_poolToken | address | The address of the pool token to swap for, e.g., NCT | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | amounts The amount of MATIC required in order to swap for the specified amount of the pool token | +| Name | Type | Description | +| --------- | ------- | --------------------------------------------------------------------------------------- | +| amountOut | uint256 | Resulting amount of Toucan pool token that got acquired for the swapped native tokens . | -### calculateExpectedPoolTokenForETH +### withdraw ```solidity -function calculateExpectedPoolTokenForETH(uint256 _fromMaticAmount, address _toToken) public view returns (uint256) +function withdraw(address _erc20Addr, uint256 _amount) public ``` -Calculates the expected amount of Toucan Pool token that can be -acquired by swapping the provided amount of MATIC. - -#### Parameters - -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromMaticAmount | uint256 | The amount of MATIC to swap | -| _toToken | address | The address of the pool token to swap for, for example, NCT or BCT | - -#### Return Values - -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | The expected amount of Pool token that can be acquired | +Allow users to withdraw tokens they have deposited. -### swapExactOutETH +### deposit ```solidity -function swapExactOutETH(address _toToken, uint256 _toAmount) public payable +function deposit(address _erc20Addr, uint256 _amount) public ``` -Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. -Remaining MATIC that was not consumed by the swap is returned. - -#### Parameters +Allow users to deposit BCT / NCT. -| Name | Type | Description | -| ---- | ---- | ----------- | -| _toToken | address | Token to swap for (will be held within contract) | -| _toAmount | uint256 | Amount of NCT / BCT wanted | +_Needs to be approved_ -### swapExactInETH +### calculateNeededTokenAmount ```solidity -function swapExactInETH(address _toToken) public payable returns (uint256) +function calculateNeededTokenAmount(address _fromToken, address _poolToken, uint256 _toAmount) public view returns (uint256 amountIn) ``` -Swap MATIC for Toucan pool tokens (BCT/NCT) on SushiSwap. All -provided MATIC will be swapped. +Return how much of the specified ERC20 token is required in +order to swap for the desired amount of a Toucan pool token, for +example, e.g., NCT. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _toToken | address | Token to swap for (will be held within contract) | +| Name | Type | Description | +| ----------- | ------- | ---------------------------------------------------- | +| \_fromToken | address | The address of the ERC20 token used for the swap | +| \_poolToken | address | The address of the pool token to swap for, e.g., NCT | +| \_toAmount | uint256 | The desired amount of pool token to receive | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| [0] | uint256 | Resulting amount of Toucan pool token that got acquired for the swapped MATIC. | +| Name | Type | Description | +| -------- | ------- | -------------------------------------------------------------------------------------------------- | +| amountIn | uint256 | The amount of the ERC20 token required in order to swap for the specified amount of the pool token | -### withdraw +### calculateNeededETHAmount ```solidity -function withdraw(address _erc20Addr, uint256 _amount) public +function calculateNeededETHAmount(address _poolToken, uint256 _toAmount) public view returns (uint256 amountIn) ``` -Allow users to withdraw tokens they have deposited. +Return how much native tokens e.g, MATIC is required in order to swap for the +desired amount of a Toucan pool token, e.g., NCT. -### deposit +#### Parameters -```solidity -function deposit(address _erc20Addr, uint256 _amount) public -``` +| Name | Type | Description | +| ----------- | ------- | ----------------------------------------------------------- | +| \_poolToken | address | The address of the pool token to swap for, for example, NCT | +| \_toAmount | uint256 | The desired amount of pool token to receive | -Allow users to deposit BCT / NCT. +#### Return Values -_Needs to be approved_ +| Name | Type | Description | +| -------- | ------- | ------------------------------------------------------------------------------------------------ | +| amountIn | uint256 | The amount of native tokens required in order to swap for the specified amount of the pool token | -### autoRedeem +### calculateExpectedPoolTokenForToken ```solidity -function autoRedeem(address _fromToken, uint256 _amount) public returns (address[] tco2s, uint256[] amounts) +function calculateExpectedPoolTokenForToken(address _fromToken, address _poolToken, uint256 _fromAmount) public view returns (uint256 amountOut) ``` -Redeems the specified amount of NCT / BCT for TCO2. - -_Needs to be approved on the client side_ +Calculates the expected amount of Toucan Pool token that can be +acquired by swapping the provided amount of ERC20 token. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _fromToken | address | Could be the address of NCT or BCT | -| _amount | uint256 | Amount to redeem | +| Name | Type | Description | +| ------------ | ------- | ---------------------------------------------------- | +| \_fromToken | address | The address of the ERC20 token used for the swap | +| \_poolToken | address | The address of the pool token to swap for, e.g., NCT | +| \_fromAmount | uint256 | The amount of ERC20 token to swap | #### Return Values -| Name | Type | Description | -| ---- | ---- | ----------- | -| tco2s | address[] | An array of the TCO2 addresses that were redeemed | -| amounts | uint256[] | An array of the amounts of each TCO2 that were redeemed | +| Name | Type | Description | +| --------- | ------- | ------------------------------------------------------ | +| amountOut | uint256 | The expected amount of Pool token that can be acquired | -### autoRetire +### calculateExpectedPoolTokenForETH ```solidity -function autoRetire(address[] _tco2s, uint256[] _amounts) public +function calculateExpectedPoolTokenForETH(address _poolToken, uint256 _fromTokenAmount) public view returns (uint256 amountOut) ``` -Retire the specified TCO2 tokens. +Calculates the expected amount of Toucan Pool token that can be +acquired by swapping the provided amount of native tokens e.g., MATIC. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _tco2s | address[] | The addresses of the TCO2s to retire | -| _amounts | uint256[] | The amounts to retire from each of the corresponding TCO2 addresses | +| Name | Type | Description | +| ----------------- | ------- | ---------------------------------------------------- | +| \_poolToken | address | The address of the pool token to swap for, e.g., NCT | +| \_fromTokenAmount | uint256 | The amount of native tokens to swap | + +#### Return Values + +| Name | Type | Description | +| --------- | ------- | ------------------------------------------------------ | +| amountOut | uint256 | The expected amount of Pool token that can be acquired | ### calculateExactOutSwap @@ -533,10 +562,10 @@ Change or add eligible tokens and their addresses. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _tokenSymbol | string | The symbol of the token to add | -| _address | address | The address of the token to add | +| Name | Type | Description | +| ------------- | ------- | ------------------------------- | +| \_tokenSymbol | string | The symbol of the token to add | +| \_address | address | The address of the token to add | ### deleteEligibleTokenAddress @@ -548,9 +577,9 @@ Delete eligible tokens stored in the contract. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _tokenSymbol | string | The symbol of the token to remove | +| Name | Type | Description | +| ------------- | ------ | --------------------------------- | +| \_tokenSymbol | string | The symbol of the token to remove | ### setToucanContractRegistry @@ -562,7 +591,6 @@ Change the TCO2 contracts registry. #### Parameters -| Name | Type | Description | -| ---- | ---- | ----------- | -| _address | address | The address of the Toucan contract registry to use | - +| Name | Type | Description | +| --------- | ------- | -------------------------------------------------- | +| \_address | address | The address of the Toucan contract registry to use | diff --git a/docs/OffsetHelperStorage.md b/docs/OffsetHelperStorage.md index 3b5defc..9621b4e 100644 --- a/docs/OffsetHelperStorage.md +++ b/docs/OffsetHelperStorage.md @@ -14,10 +14,28 @@ mapping(string => address) eligibleTokenAddresses address contractRegistryAddress ``` -### sushiRouterAddress +### poolAddresses ```solidity -address sushiRouterAddress +address[] poolAddresses +``` + +### tokenSymbolsForPaths + +```solidity +string[] tokenSymbolsForPaths +``` + +### paths + +```solidity +address[][] paths +``` + +### dexRouterAddress + +```solidity +address dexRouterAddress ``` ### balances @@ -25,4 +43,3 @@ address sushiRouterAddress ```solidity mapping(address => mapping(address => uint256)) balances ``` - From 70d2e139639334324580ace9428bb7ddf135a535 Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Thu, 14 Sep 2023 19:09:40 +0100 Subject: [PATCH 11/12] review: apply review rename nativeTokenChain function, exchange while function for for loop review: apply review rename nativeTokenChain function, exchange while function for for loop --- contracts/OffsetHelper.sol | 42 +++++++++++++++++++++----------------- contracts/test/Swapper.sol | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 6e451af..580d36d 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -77,21 +77,21 @@ contract OffsetHelper is OffsetHelperStorage { ); modifier onlyRedeemable(address _token) { - require(isRedeemable(_token), "Token not redeemable"); + require(isRedeemable(_token), "Token not redeemable."); _; } modifier onlySwappable(address _token) { - require(isSwappable(_token), "Path doesn't yet exists."); + require(isSwappable(_token), "Path doesn't yet exist."); _; } - modifier nativeTokenChain() { + modifier isCelo() { require( block.chainid != CELO_MAINNET_CHAINID, - "The function is not available on this network." + "The function is not available on Celo." ); _; @@ -126,7 +126,7 @@ contract OffsetHelper is OffsetHelperStorage { while (i < eligibleSwapPathsBySymbolLen) { eligibleSwapPaths[_paths[i][0]] = _paths[i]; eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i]; - i += 1; + i++; } } @@ -263,7 +263,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable - nativeTokenChain + isCelo returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -299,7 +299,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable - nativeTokenChain + isCelo returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -395,12 +395,8 @@ contract OffsetHelper is OffsetHelperStorage { require(tco2sLen == _amounts.length, "Arrays unequal"); - uint256 i = 0; - while (i < tco2sLen) { + for (uint i = 0; i < tco2sLen; i++) { if (_amounts[i] == 0) { - unchecked { - i++; - } continue; } require( @@ -411,10 +407,6 @@ contract OffsetHelper is OffsetHelperStorage { balances[msg.sender][_tco2s[i]] -= _amounts[i]; IToucanCarbonOffsets(_tco2s[i]).retire(_amounts[i]); - - unchecked { - ++i; - } } } @@ -518,7 +510,7 @@ contract OffsetHelper is OffsetHelperStorage { function swapExactOutETH( address _poolToken, uint256 _toAmount - ) public payable nativeTokenChain onlyRedeemable(_poolToken) { + ) public payable isCelo onlyRedeemable(_poolToken) { // create path & amounts // wrap the native token address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; @@ -553,7 +545,13 @@ contract OffsetHelper is OffsetHelperStorage { */ function swapExactInETH( address _poolToken - ) public payable onlyRedeemable(_poolToken) returns (uint256 amountOut) { + ) + public + payable + isCelo + onlyRedeemable(_poolToken) + returns (uint256 amountOut) + { // create path & amounts uint256 fromAmount = msg.value; // wrap the native token @@ -704,7 +702,13 @@ contract OffsetHelper is OffsetHelperStorage { function calculateExpectedPoolTokenForETH( address _poolToken, uint256 _fromTokenAmount - ) public view onlyRedeemable(_poolToken) returns (uint256 amountOut) { + ) + public + view + isCelo + onlyRedeemable(_poolToken) + returns (uint256 amountOut) + { address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; (, uint256[] memory amounts) = calculateExactInSwap( fromToken, diff --git a/contracts/test/Swapper.sol b/contracts/test/Swapper.sol index 7fcb5b0..1248c9a 100644 --- a/contracts/test/Swapper.sol +++ b/contracts/test/Swapper.sol @@ -22,7 +22,7 @@ contract Swapper { uint256 eligibleSwapPathsLen = _paths.length; while (i < eligibleSwapPathsLen) { eligibleSwapPaths[_paths[i][0]] = _paths[i]; - i += 1; + i++; } } From f411e27b60d0af93581a1bd8610ae0b6b6df823f Mon Sep 17 00:00:00 2001 From: GigaHierz Date: Mon, 18 Sep 2023 13:20:21 +0100 Subject: [PATCH 12/12] review: refactor Contract from UpgradableOwnable to Ownable, add chainID for Alfajores --- contracts/OffsetHelper.sol | 40 +++++++++++++------------------ contracts/OffsetHelperStorage.sol | 4 ++-- test/OffsetHelper.test.ts | 2 -- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/contracts/OffsetHelper.sol b/contracts/OffsetHelper.sol index 580d36d..984217d 100644 --- a/contracts/OffsetHelper.sol +++ b/contracts/OffsetHelper.sol @@ -56,8 +56,10 @@ import "./interfaces/IToucanContractRegistry.sol"; */ contract OffsetHelper is OffsetHelperStorage { using SafeERC20 for IERC20; - // Chain ID of Celo mainnet + // As Celo allows to pay the gas fees with other tokens than the native token, + // it's not possible ot use the swapETH (swap native tokens) functions. uint256 private constant CELO_MAINNET_CHAINID = 42220; + uint256 private constant ALFAJORES_MAINNET_CHAINID = 44787; /** * @notice Emitted upon successful redemption of TCO2 tokens from a Toucan @@ -88,9 +90,10 @@ contract OffsetHelper is OffsetHelperStorage { _; } - modifier isCelo() { + modifier isNotCelo() { require( - block.chainid != CELO_MAINNET_CHAINID, + block.chainid != CELO_MAINNET_CHAINID && + block.chainid != ALFAJORES_MAINNET_CHAINID, "The function is not available on Celo." ); @@ -121,12 +124,10 @@ contract OffsetHelper is OffsetHelperStorage { paths = _paths; dexRouterAddress = _dexRouterAddress; - uint256 i = 0; uint256 eligibleSwapPathsBySymbolLen = _tokenSymbolsForPaths.length; - while (i < eligibleSwapPathsBySymbolLen) { + for (uint256 i; i < eligibleSwapPathsBySymbolLen; i++) { eligibleSwapPaths[_paths[i][0]] = _paths[i]; eligibleSwapPathsBySymbol[_tokenSymbolsForPaths[i]] = _paths[i]; - i++; } } @@ -134,16 +135,6 @@ contract OffsetHelper is OffsetHelperStorage { // in the native tokens to token swap fails receive() external payable {} - fallback() external payable {} - - // ---------------------------------------- - // Upgradable related functions - // ---------------------------------------- - - function initialize() external virtual initializer { - __Ownable_init_unchained(); - } - // ---------------------------------------- // Public functions // ---------------------------------------- @@ -263,7 +254,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable - isCelo + isNotCelo returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -299,7 +290,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable - isCelo + isNotCelo returns (address[] memory tco2s, uint256[] memory amounts) { // swap native tokens for BCT / NCT @@ -373,8 +364,11 @@ contract OffsetHelper is OffsetHelperStorage { // update balances balances[msg.sender][_fromToken] -= _amount; uint256 tco2sLen = tco2s.length; - for (uint256 index = 0; index < tco2sLen; index++) { - balances[msg.sender][tco2s[index]] += amounts[index]; + for (uint256 i; i < tco2sLen; ) { + balances[msg.sender][tco2s[i]] += amounts[i]; + unchecked { + i++; + } } emit Redeemed(msg.sender, _fromToken, tco2s, amounts); @@ -510,7 +504,7 @@ contract OffsetHelper is OffsetHelperStorage { function swapExactOutETH( address _poolToken, uint256 _toAmount - ) public payable isCelo onlyRedeemable(_poolToken) { + ) public payable isNotCelo onlyRedeemable(_poolToken) { // create path & amounts // wrap the native token address fromToken = eligibleSwapPathsBySymbol["WMATIC"][0]; @@ -548,7 +542,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public payable - isCelo + isNotCelo onlyRedeemable(_poolToken) returns (uint256 amountOut) { @@ -705,7 +699,7 @@ contract OffsetHelper is OffsetHelperStorage { ) public view - isCelo + isNotCelo onlyRedeemable(_poolToken) returns (uint256 amountOut) { diff --git a/contracts/OffsetHelperStorage.sol b/contracts/OffsetHelperStorage.sol index 441e78f..8b875ff 100644 --- a/contracts/OffsetHelperStorage.sol +++ b/contracts/OffsetHelperStorage.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.0; -import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; -contract OffsetHelperStorage is OwnableUpgradeable { +contract OffsetHelperStorage is Ownable { // token symbol => token address mapping(address => address[]) public eligibleSwapPaths; mapping(string => address[]) public eligibleSwapPathsBySymbol; diff --git a/test/OffsetHelper.test.ts b/test/OffsetHelper.test.ts index a103153..cbfd9de 100644 --- a/test/OffsetHelper.test.ts +++ b/test/OffsetHelper.test.ts @@ -55,8 +55,6 @@ describe("OffsetHelper", function () { routerAddress ); - await offsetHelper.initialize(); - const bct = IToucanPoolToken__factory.connect( networkPoolAddress.BCT, owner