From 0ed09d1cbc47e586e812f7c9f193e90f1f8c20c9 Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Tue, 30 Jul 2024 07:14:12 -0700 Subject: [PATCH] PeggyJV Arbitrum deployments --- resources/PeggyJVContractDeploymentNames.sol | 88 +++++ .../peggyjv_production/DeployDeployer.s.sol | 28 ++ .../SetupTestProductionInfra.s.sol | 363 ++++++++++++++++++ .../Arbitrum/ArbitrumAddressesPeggyJV.sol | 145 +++++++ 4 files changed, 624 insertions(+) create mode 100644 resources/PeggyJVContractDeploymentNames.sol create mode 100644 script/Arbitrum/peggyjv_production/DeployDeployer.s.sol create mode 100644 script/Arbitrum/peggyjv_production/SetupTestProductionInfra.s.sol create mode 100644 test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol diff --git a/resources/PeggyJVContractDeploymentNames.sol b/resources/PeggyJVContractDeploymentNames.sol new file mode 100644 index 000000000..dab9e9112 --- /dev/null +++ b/resources/PeggyJVContractDeploymentNames.sol @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.21; + +contract ContractDeploymentNames { + // Infrastructure + string public registryName = "PJV Registry V0.0"; + string public priceRouterName = "PJV PriceRouter V0.1"; + string public timelockOwnerName = "PJV Timelock Owner V0.0"; + string public protocolFeeCollectorName = "PJV Protocol Fee Collector V0.0"; + string public feesAndReservesName = "PJV Fees And Reserves V0.0"; + string public withdrawQueueName = "PJV Withdraw Queue V0.0"; + string public simpleSolverName = "PJV Simple Solver V0.0"; + string public atomicQueueName = "PJV Atomic Queue V0.0"; + string public incentiveDistributorName = "PJV Incentive Distributor V0.1"; + // Adaptors + string public erc20AdaptorName = "PJV ERC20 Adaptor V0.0"; + string public erc4626AdaptorName = "PJV ERC4626 Adaptor V0.0"; + string public oneInchAdaptorName = "PJV 1Inch Adaptor V0.0"; + string public zeroXAdaptorName = "PJV 0x Adaptor V0.0"; + string public uniswapV3AdaptorName = "PJV Uniswap V3 Adaptor V0.0"; + string public uniswapV3PositionTrackerName = "PJV Uniswap V3 Position Tracker V0.0"; + string public swapWithUniswapAdaptorName = "PJV Swap With Uniswap Adaptor V0.0"; + string public aaveV3ATokenAdaptorName = "PJV Aave V3 AToken Adaptor V0.0"; + string public aaveV3DebtTokenAdaptorName = "PJV Aave V3 Debt Token Adaptor V0.0"; + string public compoundV3SupplyAdaptorName = "PJV Compound V3 Supply Adaptor V 0.0"; + string public compoundV3RewardsAdaptorName = "PJV Compound V3 Rewards Adaptor V 0.0"; + string public feesAndReservesAdaptorName = "PJV Fees And Reserves Adaptor V 0.0"; + string public balancerPoolAdaptorName = "PJV Balancer Pool Adaptor V 0.0"; + // Deploy below only after it has been confirmed that they will work on L2 + string public balancerV2PoolAdaptorName = "PJV Balancer Pool Adaptor V 0.0"; + string public auraAdaptorName = "PJV Aura ERC4626 Adaptor V 0.0"; + string public curveAdaptorName = "PJV Curve Adaptor V 0.0"; + string public convexCurveAdaptorName = "PJV Convex Curve Adaptor V 0.0"; + + // Vault Names + string public realYieldUsdName = "Real Yield USD V0.0"; + string public realYieldEthName = "Real Yield ETH V0.1"; + string public realYieldMaticName = "Real Yield MATIC V0.0"; + string public realYieldAvaxName = "Real Yield AVAX V0.0"; + string public turboRSETHName = "Turbo RSETH V0.0"; + string public turboEZETHName = "Turbo EZETH V0.0"; + + // Share Price Oracle Names + string public realYieldUsdSharePriceOracleName = "Real Yield USD Share Price Oracle V0.0"; + string public realYieldEthSharePriceOracleName = "Real Yield ETH Share Price Oracle V0.1"; + string public realYieldMaticSharePriceOracleName = "Real Yield MATIC Share Price Oracle V0.0"; + string public realYieldAvaxSharePriceOracleName = "Real Yield AVAX Share Price Oracle V0.0"; + + // Cellar Staking Contracts + string public realYieldUsdStakingName = "Real Yield USD Staking V0.0"; + string public realYieldEthStakingName = "Real Yield ETH Staking V0.1"; + // Mainnet + // TODO morpho adaptors + // aave v2 adaptors + + // PRODUCTION_REGISTRY_V3 = { + // ERC20_ADAPTOR_NAME: "0xa5D315eA3D066160651459C4123ead9264130BFd", + // UNIV3_ADAPTOR_NAME: "0xC74fFa211A8148949a77ec1070Df7013C8D5Ce92", + // ONE_INCH_ADAPTOR_NAME: "0xB8952ce4010CFF3C74586d712a4402285A3a3AFb", + // ZEROX_ADAPTOR_NAME: "0x1039a9b61DFF6A3fb8dbF4e924AA749E5cFE35ef", + // SWAP_WITH_UNISWAP_ADAPTOR_NAME: "0xd6BC6Df1ed43e3101bC27a4254593a06598a3fDD", + // f"{BALANCER_POOL_ADAPTOR_NAME} (Deprecated)": "0xa05322534381D371Bf095E031D939f54faA33823", + // FEES_AND_RESERVES_ADAPTOR_NAME: "0x647d264d800A2461E594796af61a39b7735d8933", + // MORPHO_AAVEV2_ATOKEN_ADAPTOR_NAME: "0xD11142d10f4E5f12A97E6702cc43E598dC77B2D6", + // MORPHO_AAVEV3_P2P_ADAPTOR_NAME: "0x0Dd5d6bA17f223b51f46D4Ed5231cFBf929cFdEe", + // AAVEV3_ATOKEN_ADAPTOR_NAME: "0x76Cef5606C8b6bA38FE2e3c639E1659afA530b47", + // AAVEV3_DEBTTOKEN_ADAPTOR_NAME: "0x6DEd49176a69bEBf8dC1a4Ea357faa555df188f7", + // MORPHO_AAVEV2_DEBTTOKEN_ADAPTOR_NAME: "0x407D5489F201013EE6A6ca20fCcb05047C548138", + // LEGACY_CELLAR_ADAPTOR_NAME: "0x1e22aDf9E63eF8F2A3626841DDdDD19683E31068", + // VESTING_SIMPLE_ADAPTOR_NAME: "0x3b98BA00f981342664969e609Fb88280704ac479", + // AAVE_ATOKEN_ADAPTOR_NAME: "0xe3A3b8AbbF3276AD99366811eDf64A0a4b30fDa2", + // AAVE_DEBTTOKEN_ADAPTOR_NAME: "0xeC86ac06767e911f5FdE7cba5D97f082C0139C01", + // MORPHO_AAVEV3_ATOKEN_ADAPTOR_NAME: "0xB46E8a03b1AaFFFb50f281397C57b5B87080363E", + // MORPHO_AAVEV3_DEBTTOKEN_ADAPTOR_NAME: "0x25a61f771aF9a38C10dDd93c2bBAb39a88926fa9", + // f"{AAVE_ATOKEN_ADAPTOR_NAME} 1.02HF": "0x76282f60d541Ec41b26ac8fC0F6922337ADE0a86", + // f"{AAVE_DEBTTOKEN_ADAPTOR_NAME} 1.02HF": "0x1de3C2790E958BeDe9cA26e93169dBDfEF5A94B2", + // f"{AAVEV3_ATOKEN_ADAPTOR_NAME} 1.02HF": "0x96916a05c09f78B831c7bfC6e10e991A6fbeE1B3", + // f"{AAVEV3_DEBTTOKEN_ADAPTOR_NAME} 1.02HF": "0x0C74c849cC9aaACDe78d8657aBD6812C675726Fb", + // f"{MORPHO_AAVEV2_ATOKEN_ADAPTOR_NAME} 1.02HF": "0xD8224b856DdB3227CC0dCCb59BCBB5236651E25F", + // f"{MORPHO_AAVEV2_DEBTTOKEN_ADAPTOR_NAME} 1.02HF": "0xc852e0835eFaFeEF3B4d5bfEF41AA52D0E4eeD98", + // f"{MORPHO_AAVEV3_ATOKEN_ADAPTOR_NAME} 1.02HF": "0x84E7ea073bFd8c409678dBd17EC481dC9AD7Dcd9", + // f"{MORPHO_AAVEV3_DEBTTOKEN_ADAPTOR_NAME} 1.02HF": "0xf7C64ED003C997BD88DC5f1081eFBBE607400Df0", + // BALANCER_POOL_ADAPTOR_NAME: "0x2750348A897059C45683d33A1742a3989454F7d6", + // f"{VESTING_SIMPLE_ADAPTOR_NAME} SOMM": "0x8a95BBAbb0039480F6DD90fe856c1E0c3D575aA1", + // CELLAR_ADAPTOR_NAME: "0x3B5CA5de4d808Cd793d3a7b3a731D3E67E707B27", + // AAVE_ENABLE_ASSET_AS_COLLATERAL_ADAPTOR_NAME: "0x724FEb5819D1717Aec5ADBc0974a655a498b2614", + // } +} diff --git a/script/Arbitrum/peggyjv_production/DeployDeployer.s.sol b/script/Arbitrum/peggyjv_production/DeployDeployer.s.sol new file mode 100644 index 000000000..9ceccae4e --- /dev/null +++ b/script/Arbitrum/peggyjv_production/DeployDeployer.s.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.21; + +import { Deployer } from "src/Deployer.sol"; + +import { ArbitrumAddresses } from "test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol"; + +import "forge-std/Script.sol"; + +/** + * @dev Run + * source .env && forge script script/Arbitrum/peggyjv_production/DeployDeployer.s.sol:DeployDeployerScript --evm-version london --with-gas-price 100000000 --slow --broadcast --etherscan-api-key $ARBISCAN_KEY --verify --private-key $PRIVATE_KEY —optimize —optimizer-runs 200 + + * @dev Optionally can change `--with-gas-price` to something more reasonable + */ +contract DeployDeployerScript is Script, ArbitrumAddresses { + Deployer public deployer = Deployer(deployerAddress); + + function run() external { + address[] memory deployers = new address[](2); + deployers[0] = dev0Address; + + vm.startBroadcast(); + new Deployer(dev0Address, deployers); + deployer.transferOwnership(dev0Address); + vm.stopBroadcast(); + } +} diff --git a/script/Arbitrum/peggyjv_production/SetupTestProductionInfra.s.sol b/script/Arbitrum/peggyjv_production/SetupTestProductionInfra.s.sol new file mode 100644 index 000000000..6af7878ce --- /dev/null +++ b/script/Arbitrum/peggyjv_production/SetupTestProductionInfra.s.sol @@ -0,0 +1,363 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.21; + +import { Deployer } from "src/Deployer.sol"; +import { Registry } from "src/Registry.sol"; +import { PriceRouter } from "src/modules/price-router/PriceRouter.sol"; +import { SequencerPriceRouter } from "src/modules/price-router/permutations/SequencerPriceRouter.sol"; +import { ERC20Adaptor } from "src/modules/adaptors/ERC20Adaptor.sol"; +import { SwapWithUniswapAdaptor } from "src/modules/adaptors/Uniswap/SwapWithUniswapAdaptor.sol"; +import { UniswapV3PositionTracker } from "src/modules/adaptors/Uniswap/UniswapV3PositionTracker.sol"; +import { UniswapV3Adaptor } from "src/modules/adaptors/Uniswap/UniswapV3Adaptor.sol"; +import { AaveV3ATokenAdaptor } from "src/modules/adaptors/Aave/V3/AaveV3ATokenAdaptor.sol"; +import { AaveV3DebtTokenAdaptor } from "src/modules/adaptors/Aave/V3/AaveV3DebtTokenAdaptor.sol"; +import { ERC4626Adaptor } from "src/modules/adaptors/ERC4626Adaptor.sol"; +import { OneInchAdaptor } from "src/modules/adaptors/OneInch/OneInchAdaptor.sol"; +import { ZeroXAdaptor } from "src/modules/adaptors/ZeroX/ZeroXAdaptor.sol"; +import { IChainlinkAggregator } from "src/interfaces/external/IChainlinkAggregator.sol"; +import { UniswapV3Pool } from "src/interfaces/external/UniswapV3Pool.sol"; +import { ArbitrumAddresses } from "test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol"; +import { ContractDeploymentNames } from "resources/PeggyJVContractDeploymentNames.sol"; + +import { PositionIds } from "resources/PositionIds.sol"; +import { Math } from "src/utils/Math.sol"; + +import "forge-std/Script.sol"; +import "forge-std/StdJson.sol"; + +/** + * source .env && forge script script/Arbitrum/peggyjv_production/SetupTestProductionInfra.s.sol:SetUpArchitectureScript --evm-version london --with-gas-price 100000000 --slow --broadcast --etherscan-api-key $ARBISCAN_KEY --verify + * @dev Optionally can change `--with-gas-price` to something more reasonable + */ +contract SetUpArchitectureScript is Script, ArbitrumAddresses, ContractDeploymentNames, PositionIds { + using Math for uint256; + using stdJson for string; + + uint256 public privateKey; + Deployer public deployer = Deployer(deployerAddress); + Registry public registry; + PriceRouter public priceRouter; + address public erc20Adaptor; + address public swapWithUniswapAdaptor; + address public uniswapV3Adaptor; + address public aaveV3ATokenAdaptor; + address public aaveV3DebtTokenAdaptor; + address public erc4626Adaptor; + address public oneInchAdaptor; + address public zeroXAdaptor; + + uint256 public constant AAVE_V3_MIN_HEALTH_FACTOR = 1.01e18; + + uint8 public constant CHAINLINK_DERIVATIVE = 1; + uint8 public constant TWAP_DERIVATIVE = 2; + uint8 public constant EXTENSION_DERIVATIVE = 3; + + function setUp() external { + privateKey = vm.envUint("PRIVATE_KEY"); + } + + function run() external { + bytes memory creationCode; + bytes memory constructorArgs; + vm.createSelectFork("arbitrum"); + vm.startBroadcast(privateKey); + // Deploy Registry + creationCode = type(Registry).creationCode; + constructorArgs = abi.encode(dev0Address, dev0Address, address(0), address(0)); + registry = Registry(deployer.deployContract(registryName, creationCode, constructorArgs, 0)); + + // Deploy Price Router + creationCode = type(SequencerPriceRouter).creationCode; + constructorArgs = abi.encode(ARB_SEQUENCER_UPTIME_FEED, uint256(3_600), dev0Address, registry, WETH); + priceRouter = PriceRouter(deployer.deployContract(priceRouterName, creationCode, constructorArgs, 0)); + + // Update price router in registry. + registry.setAddress(2, address(priceRouter)); + + // Deploy ERC20Adaptor. + creationCode = type(ERC20Adaptor).creationCode; + constructorArgs = hex""; + erc20Adaptor = deployer.deployContract(erc20AdaptorName, creationCode, constructorArgs, 0); + + // Deploy SwapWithUniswapAdaptor. + creationCode = type(SwapWithUniswapAdaptor).creationCode; + constructorArgs = abi.encode(uniV2Router, uniV3Router); + swapWithUniswapAdaptor = deployer.deployContract(swapWithUniswapAdaptorName, creationCode, constructorArgs, 0); + + // Deploy Uniswap V3 Adaptor. + creationCode = type(UniswapV3PositionTracker).creationCode; + constructorArgs = abi.encode(uniswapV3PositionManager); + address tracker = deployer.deployContract(uniswapV3PositionTrackerName, creationCode, constructorArgs, 0); + + creationCode = type(UniswapV3Adaptor).creationCode; + constructorArgs = abi.encode(uniswapV3PositionManager, tracker); + uniswapV3Adaptor = deployer.deployContract(uniswapV3AdaptorName, creationCode, constructorArgs, 0); + + // Deploy Aave V3 Adaptors. + creationCode = type(AaveV3ATokenAdaptor).creationCode; + constructorArgs = abi.encode(aaveV3Pool, aaveV3Oracle, AAVE_V3_MIN_HEALTH_FACTOR); + aaveV3ATokenAdaptor = deployer.deployContract(aaveV3ATokenAdaptorName, creationCode, constructorArgs, 0); + + creationCode = type(AaveV3DebtTokenAdaptor).creationCode; + constructorArgs = abi.encode(aaveV3Pool, AAVE_V3_MIN_HEALTH_FACTOR); + aaveV3DebtTokenAdaptor = deployer.deployContract(aaveV3DebtTokenAdaptorName, creationCode, constructorArgs, 0); + + // Deploy ERC4626 Adaptor. + creationCode = type(ERC4626Adaptor).creationCode; + constructorArgs = hex""; + erc4626Adaptor = deployer.deployContract(erc4626AdaptorName, creationCode, constructorArgs, 0); + + // Deploy 1Inch Adaptor. + creationCode = type(OneInchAdaptor).creationCode; + constructorArgs = abi.encode(oneInchTarget); + oneInchAdaptor = deployer.deployContract(oneInchAdaptorName, creationCode, constructorArgs, 0); + + // Deploy 0x Adaptor. + creationCode = type(ZeroXAdaptor).creationCode; + constructorArgs = abi.encode(zeroXTarget); + zeroXAdaptor = deployer.deployContract(zeroXAdaptorName, creationCode, constructorArgs, 0); + + // Trust Adaptors in Registry. + registry.trustAdaptor(erc20Adaptor); + registry.trustAdaptor(swapWithUniswapAdaptor); + registry.trustAdaptor(uniswapV3Adaptor); + registry.trustAdaptor(aaveV3ATokenAdaptor); + registry.trustAdaptor(aaveV3DebtTokenAdaptor); + registry.trustAdaptor(erc4626Adaptor); + registry.trustAdaptor(oneInchAdaptor); + registry.trustAdaptor(zeroXAdaptor); + + // Add pricing. + PriceRouter.ChainlinkDerivativeStorage memory stor; + PriceRouter.AssetSettings memory settings; + + uint256 price = uint256(IChainlinkAggregator(WETH_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, WETH_USD_FEED); + priceRouter.addAsset(WETH, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(USDC_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, USDC_USD_FEED); + priceRouter.addAsset(USDC, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(USDCe_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, USDCe_USD_FEED); + priceRouter.addAsset(USDCe, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(DAI_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, DAI_USD_FEED); + priceRouter.addAsset(DAI, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(USDT_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, USDT_USD_FEED); + priceRouter.addAsset(USDT, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(LUSD_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, LUSD_USD_FEED); + priceRouter.addAsset(LUSD, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(FRAX_USD_FEED).latestAnswer()); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, FRAX_USD_FEED); + priceRouter.addAsset(FRAX, settings, abi.encode(stor), price); + + stor.inETH = true; + + price = uint256(IChainlinkAggregator(WSTETH_ETH_FEED).latestAnswer()); + price = priceRouter.getValue(WETH, price, USDC); + price = price.changeDecimals(6, 8); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, WSTETH_ETH_FEED); + priceRouter.addAsset(WSTETH, settings, abi.encode(stor), price); + + price = uint256(IChainlinkAggregator(RETH_ETH_FEED).latestAnswer()); + price = priceRouter.getValue(WETH, price, USDC); + price = price.changeDecimals(6, 8); + settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, RETH_ETH_FEED); + priceRouter.addAsset(rETH, settings, abi.encode(stor), price); + + // Add ERC20 positions for RYE and RYUSD + registry.trustPosition(ERC20_USDC_POSITION, address(erc20Adaptor), abi.encode(USDC)); + registry.trustPosition(ERC20_USDCE_POSITION, address(erc20Adaptor), abi.encode(USDCe)); + registry.trustPosition(ERC20_DAI_POSITION, address(erc20Adaptor), abi.encode(DAI)); + registry.trustPosition(ERC20_USDT_POSITION, address(erc20Adaptor), abi.encode(USDT)); + registry.trustPosition(ERC20_LUSD_POSITION, address(erc20Adaptor), abi.encode(LUSD)); + registry.trustPosition(ERC20_FRAX_POSITION, address(erc20Adaptor), abi.encode(FRAX)); + registry.trustPosition(ERC20_WETH_POSITION, address(erc20Adaptor), abi.encode(WETH)); + registry.trustPosition(ERC20_WSTETH_POSITION, address(erc20Adaptor), abi.encode(WSTETH)); + registry.trustPosition(ERC20_RETH_POSITION, address(erc20Adaptor), abi.encode(rETH)); + + // Add Aave V3 a token positions for RYE and RYUSD. + registry.trustPosition(AAVE_V3_LOW_HF_A_USDC_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3USDC)); + registry.trustPosition(AAVE_V3_LOW_HF_A_USDCE_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3USDCe)); + registry.trustPosition(AAVE_V3_LOW_HF_A_DAI_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3DAI)); + registry.trustPosition(AAVE_V3_LOW_HF_A_USDT_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3USDT)); + registry.trustPosition(AAVE_V3_LOW_HF_A_LUSD_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3LUSD)); + registry.trustPosition(AAVE_V3_LOW_HF_A_FRAX_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3FRAX)); + registry.trustPosition(AAVE_V3_LOW_HF_A_WETH_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3WETH)); + registry.trustPosition(AAVE_V3_LOW_HF_A_WSTETH_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3WSTETH)); + registry.trustPosition(AAVE_V3_LOW_HF_A_RETH_POSITION, address(aaveV3ATokenAdaptor), abi.encode(aV3rETH)); + + // Add Aave V3 debt token positions for RYE and RYUSD. + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_USDC_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3USDC)); + registry.trustPosition( + AAVE_V3_LOW_HF_DEBT_USDCE_POSITION, + address(aaveV3DebtTokenAdaptor), + abi.encode(dV3USDCe) + ); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_DAI_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3DAI)); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_USDT_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3USDT)); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_LUSD_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3LUSD)); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_FRAX_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3FRAX)); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_WETH_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3WETH)); + registry.trustPosition( + AAVE_V3_LOW_HF_DEBT_WSTETH_POSITION, + address(aaveV3DebtTokenAdaptor), + abi.encode(dV3WSTETH) + ); + registry.trustPosition(AAVE_V3_LOW_HF_DEBT_RETH_POSITION, address(aaveV3DebtTokenAdaptor), abi.encode(dV3rETH)); + + // Add Uniswap V3 positions for RYE and RYUSD. + registry.trustPosition( + UNISWAP_V3_USDC_USDCE_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDC) < address(USDCe) ? [USDC, USDCe] : [USDCe, USDC]) + ); + _checkTokenOrdering(UNISWAP_V3_USDC_USDCE_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDC_DAI_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDC) < address(DAI) ? [USDC, DAI] : [DAI, USDC]) + ); + _checkTokenOrdering(UNISWAP_V3_USDC_DAI_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDC_USDT_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDC) < address(USDT) ? [USDC, USDT] : [USDT, USDC]) + ); + _checkTokenOrdering(UNISWAP_V3_USDC_USDT_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDC_LUSD_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDC) < address(LUSD) ? [USDC, LUSD] : [LUSD, USDC]) + ); + _checkTokenOrdering(UNISWAP_V3_USDC_LUSD_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDC_FRAX_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDC) < address(FRAX) ? [USDC, FRAX] : [FRAX, USDC]) + ); + _checkTokenOrdering(UNISWAP_V3_USDC_FRAX_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDCE_DAI_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDCe) < address(DAI) ? [USDCe, DAI] : [DAI, USDCe]) + ); + _checkTokenOrdering(UNISWAP_V3_USDCE_DAI_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDCE_USDT_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDCe) < address(USDT) ? [USDCe, USDT] : [USDT, USDCe]) + ); + _checkTokenOrdering(UNISWAP_V3_USDCE_USDT_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDCE_LUSD_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDCe) < address(LUSD) ? [USDCe, LUSD] : [LUSD, USDCe]) + ); + _checkTokenOrdering(UNISWAP_V3_USDCE_LUSD_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDCE_FRAX_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDCe) < address(FRAX) ? [USDCe, FRAX] : [FRAX, USDCe]) + ); + _checkTokenOrdering(UNISWAP_V3_USDCE_FRAX_POSITION); + + registry.trustPosition( + UNISWAP_V3_DAI_USDT_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(DAI) < address(USDT) ? [DAI, USDT] : [USDT, DAI]) + ); + _checkTokenOrdering(UNISWAP_V3_DAI_USDT_POSITION); + + registry.trustPosition( + UNISWAP_V3_DAI_LUSD_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(DAI) < address(LUSD) ? [DAI, LUSD] : [LUSD, DAI]) + ); + _checkTokenOrdering(UNISWAP_V3_DAI_LUSD_POSITION); + + registry.trustPosition( + UNISWAP_V3_DAI_FRAX_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(DAI) < address(FRAX) ? [DAI, FRAX] : [FRAX, DAI]) + ); + _checkTokenOrdering(UNISWAP_V3_DAI_FRAX_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDT_LUSD_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDT) < address(LUSD) ? [USDT, LUSD] : [LUSD, USDT]) + ); + _checkTokenOrdering(UNISWAP_V3_USDT_LUSD_POSITION); + + registry.trustPosition( + UNISWAP_V3_USDT_FRAX_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(USDT) < address(FRAX) ? [USDT, FRAX] : [FRAX, USDT]) + ); + _checkTokenOrdering(UNISWAP_V3_USDT_FRAX_POSITION); + + registry.trustPosition( + UNISWAP_V3_LUSD_FRAX_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(LUSD) < address(FRAX) ? [LUSD, FRAX] : [FRAX, LUSD]) + ); + _checkTokenOrdering(UNISWAP_V3_LUSD_FRAX_POSITION); + + registry.trustPosition( + UNISWAP_V3_WETH_WSTETH_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(WETH) < address(WSTETH) ? [WETH, WSTETH] : [WSTETH, WETH]) + ); + _checkTokenOrdering(UNISWAP_V3_WETH_WSTETH_POSITION); + + registry.trustPosition( + UNISWAP_V3_WETH_RETH_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(WETH) < address(rETH) ? [WETH, rETH] : [rETH, WETH]) + ); + _checkTokenOrdering(UNISWAP_V3_WETH_RETH_POSITION); + + registry.trustPosition( + UNISWAP_V3_WSTETH_RETH_POSITION, + address(uniswapV3Adaptor), + abi.encode(address(WSTETH) < address(rETH) ? [WSTETH, rETH] : [rETH, WSTETH]) + ); + _checkTokenOrdering(UNISWAP_V3_WSTETH_RETH_POSITION); + + vm.stopBroadcast(); + } + + function _checkTokenOrdering(uint32 registryId) internal view { + (, , bytes memory data, ) = registry.getPositionIdToPositionData(registryId); + (address token0, address token1) = abi.decode(data, (address, address)); + if (token1 < token0) revert("Tokens out of order"); + UniswapV3Pool pool = IUniswapV3Factory(uniswapV3Factory).getPool(token0, token1, 100); + if (address(pool) == address(0)) pool = IUniswapV3Factory(uniswapV3Factory).getPool(token0, token1, 500); + if (address(pool) == address(0)) pool = IUniswapV3Factory(uniswapV3Factory).getPool(token0, token1, 3000); + if (address(pool) != address(0)) { + if (pool.token0() != token0) revert("Token 0 mismtach"); + if (pool.token1() != token1) revert("Token 1 mismtach"); + } + } +} + +interface IUniswapV3Factory { + function getPool(address tokenA, address tokenB, uint24 fee) external view returns (UniswapV3Pool pool); +} diff --git a/test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol b/test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol new file mode 100644 index 000000000..fcf16c7a6 --- /dev/null +++ b/test/resources/Arbitrum/ArbitrumAddressesPeggyJV.sol @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity 0.8.21; + +import { ERC20 } from "@solmate/tokens/ERC20.sol"; +import { CErc20 } from "src/interfaces/external/ICompound.sol"; + +contract ArbitrumAddresses { + // Sommelier + address public axelarProxyV0_0 = 0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2; + address public axelarGateway = 0xe432150cce91c13a887f7D836923d5597adD8E31; + string public axelarSommelierSender = "somm1lrneqhq4rq8nz2nk6vn3sanrxva7zuns8aa45g"; + address public strategist = 0xA9962a5BfBea6918E958DeE0647E99fD7863b95A; + address public devStrategist = 0xeeF7b7205CAF2Bcd71437D9acDE3874C3388c138; + address public deployerDeployerAddress = 0x61bfcdAFA35999FA93C10Ec746589EB93817a8b9; + address public dev0Address = 0xc4168e8d6346Dd69ca04606EE5FbC63E78a7a84f; + //address public dev1Address = 0x6d3655EE04820f4385a910FD1898d4Ec6241F520; + address public cosmos = address(0xCAAA); + address public multisig = address(0); + address public deployerAddress = 0x3a49B21611f70DCa6d9CB0356B8fe45fBEd56815; + // address public priceRouter = address(0); + + // DeFi Ecosystem + address public ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + address public uniV3Router = 0xE592427A0AEce92De3Edee1F18E0157C05861564; + address public uniV2Router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; + + // ERC20s + ERC20 public USDC = ERC20(0xaf88d065e77c8cC2239327C5EDb3A432268e5831); + ERC20 public USDCe = ERC20(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8); + ERC20 public WETH = ERC20(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1); + ERC20 public WBTC = ERC20(0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f); + ERC20 public USDT = ERC20(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9); + ERC20 public DAI = ERC20(0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1); + ERC20 public WSTETH = ERC20(0x5979D7b546E38E414F7E9822514be443A4800529); + ERC20 public FRAX = ERC20(0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F); + ERC20 public BAL = ERC20(0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8); + ERC20 public COMP = ERC20(0x354A6dA3fcde098F8389cad84b0182725c6C91dE); + ERC20 public LINK = ERC20(0xf97f4df75117a78c1A5a0DBb814Af92458539FB4); + ERC20 public rETH = ERC20(0xEC70Dcb4A1EFa46b8F2D97C310C9c4790ba5ffA8); + ERC20 public cbETH = ERC20(0x1DEBd73E752bEaF79865Fd6446b0c970EaE7732f); + ERC20 public LUSD = ERC20(0x93b346b6BC2548dA6A1E7d98E9a421B42541425b); + ERC20 public UNI = ERC20(0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0); + ERC20 public CRV = ERC20(0x11cDb42B0EB46D95f990BeDD4695A6e3fA034978); + ERC20 public FRXETH = ERC20(0x178412e79c25968a32e89b11f63B33F733770c2A); + ERC20 public ARB = ERC20(0x912CE59144191C1204E64559FE8253a0e49E6548); + ERC20 public WEETH = ERC20(0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe); + ERC20 public AXL_SOMM = ERC20(0x4e914bbDCDE0f455A8aC9d59d3bF739c46287Ed2); + address public WSTETH_EXCHANGE_RATE_FEED = 0xB1552C5e96B312d0Bf8b554186F846C40614a540; + address public RETH_EXCHANGE_RATE_FEED = 0xF3272CAfe65b190e76caAF483db13424a3e23dD2; + address public ARB_SEQUENCER_UPTIME_FEED = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D; + + // Chainlink Datafeeds + address public WETH_USD_FEED = 0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612; + address public USDC_USD_FEED = 0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3; + address public USDCe_USD_FEED = 0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3; + address public WBTC_USD_FEED = 0xd0C7101eACbB49F3deCcCc166d238410D6D46d57; + address public DAI_USD_FEED = 0xc5C8E77B397E531B8EC06BFb0048328B30E9eCfB; + address public USDT_USD_FEED = 0x3f3f5dF88dC9F13eac63DF89EC16ef6e7E25DdE7; + address public COMP_USD_FEED = 0xe7C53FFd03Eb6ceF7d208bC4C13446c76d1E5884; + address public FRAX_USD_FEED = 0x0809E3d38d1B4214958faf06D8b1B1a2b73f2ab8; + address public WSTETH_ETH_FEED = 0xb523AE262D20A936BC152e6023996e46FDC2A95D; + address public RETH_ETH_FEED = 0xD6aB2298946840262FcC278fF31516D39fF611eF; + address public CBETH_ETH_FEED = 0xa668682974E3f121185a3cD94f00322beC674275; + address public BAL_USD_FEED = 0xBE5eA816870D11239c543F84b71439511D70B94f; + address public LUSD_USD_FEED = 0x0411D28c94d85A36bC72Cb0f875dfA8371D8fFfF; + address public UNI_USD_FEED = 0x9C917083fDb403ab5ADbEC26Ee294f6EcAda2720; + address public CRV_USD_FEED = 0xaebDA2c976cfd1eE1977Eac079B4382acb849325; + address public ARB_USD_FEED = 0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6; + address public LINK_USD_FEED = 0x86E53CF1B870786351Da77A57575e79CB55812CB; + address public LINK_ETH_FEED = 0xb7c8Fb1dB45007F98A68Da0588e1AA524C317f27; + address public WEETH_ETH_FEED = 0x20bAe7e1De9c596f5F7615aeaa1342Ba99294e12; + + // Aave V3 Tokens + ERC20 public aV3USDC = ERC20(0x724dc807b04555b71ed48a6896b6F41593b8C637); + ERC20 public dV3USDC = ERC20(0xf611aEb5013fD2c0511c9CD55c7dc5C1140741A6); + ERC20 public aV3USDCe = ERC20(0x625E7708f30cA75bfd92586e17077590C60eb4cD); + ERC20 public dV3USDCe = ERC20(0xFCCf3cAbbe80101232d343252614b6A3eE81C989); + ERC20 public aV3WETH = ERC20(0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8); + ERC20 public dV3WETH = ERC20(0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351); + ERC20 public aV3WBTC = ERC20(0x078f358208685046a11C85e8ad32895DED33A249); + ERC20 public dV3WBTC = ERC20(0x92b42c66840C7AD907b4BF74879FF3eF7c529473); + ERC20 public aV3USDT = ERC20(0x6ab707Aca953eDAeFBc4fD23bA73294241490620); + ERC20 public dV3USDT = ERC20(0xfb00AC187a8Eb5AFAE4eACE434F493Eb62672df7); + ERC20 public aV3DAI = ERC20(0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE); + ERC20 public dV3DAI = ERC20(0x8619d80FB0141ba7F184CbF22fd724116D9f7ffC); + ERC20 public aV3WSTETH = ERC20(0x513c7E3a9c69cA3e22550eF58AC1C0088e918FFf); + ERC20 public dV3WSTETH = ERC20(0x77CA01483f379E58174739308945f044e1a764dc); + ERC20 public aV3FRAX = ERC20(0x38d693cE1dF5AaDF7bC62595A37D667aD57922e5); + ERC20 public dV3FRAX = ERC20(0x5D557B07776D12967914379C71a1310e917C7555); + ERC20 public aV3LINK = ERC20(0x191c10Aa4AF7C30e871E70C95dB0E4eb77237530); + ERC20 public dV3LINK = ERC20(0x953A573793604aF8d41F306FEb8274190dB4aE0e); + ERC20 public aV3rETH = ERC20(0x8Eb270e296023E9D92081fdF967dDd7878724424); + ERC20 public dV3rETH = ERC20(0xCE186F6Cccb0c955445bb9d10C59caE488Fea559); + ERC20 public aV3LUSD = ERC20(0x8ffDf2DE812095b1D19CB146E4c004587C0A0692); + ERC20 public dV3LUSD = ERC20(0xA8669021776Bc142DfcA87c21b4A52595bCbB40a); + ERC20 public aV3ARB = ERC20(0x6533afac2E7BCCB20dca161449A13A32D391fb00); + ERC20 public dV3ARB = ERC20(0x44705f578135cC5d703b4c9c122528C73Eb87145); + + // Balancer V2 Addresses + address public vault = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; + + // Chainlink Automation Registry + address public automationRegistry = 0x37D9dC70bfcd8BC77Ec2858836B923c560E891D1; + address public automationRegistrar = 0x86EFBD0b6736Bed994962f9797049422A3A8E8Ad; + + // FraxLend Pairs + address public ARB_FRAX_PAIR = 0x2D0483FefAbA4325c7521539a3DFaCf94A19C472; + + // Curve Pools and Tokens + + // Convex-Curve Platform Specifics + + // Uniswap V3 + + // Redstone + + // Pendle + address public pendleMarketFactory = 0x2FCb47B58350cD377f94d3821e7373Df60bD9Ced; + address public pendleRouter = 0x00000000005BBB0EF59571E58418F9a4357b68A0; + address public pendleOracle = 0x1Fd95db7B7C0067De8D45C0cb35D59796adfD187; + + address public pendleWeETHMarket = 0xE11f9786B06438456b044B3E21712228ADcAA0D1; + address public pendleWeethSy = 0xa6C895EB332E91c5b3D00B7baeEAae478cc502DA; + address public pendleEethPt = 0x9bEcd6b4Fb076348A455518aea23d3799361FE95; + address public pendleEethYt = 0xF28Db483773E3616DA91FDfa7b5D4090Ac40cC59; + + // Uniswap V3 + address public uniswapV3PositionManager = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88; + address public uniswapV3Factory = 0x1F98431c8aD98523631AE4a59f267346ea31F984; + + // Aave + address public aaveV3Pool = 0x794a61358D6845594F94dc1DB02A252b5b4814aD; + address public aaveV3Oracle = 0xb56c2F0B653B2e0b10C9b928C8580Ac5Df02C7C7; + + // 1Inch + address public oneInchTarget = 0x1111111254EEB25477B68fb85Ed929f73A960582; + + // 0x + address public zeroXTarget = 0xDef1C0ded9bec7F1a1670819833240f027b25EfF; + + // Compound V3 + address public compoundV3UsdcComet = 0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf; + address public compoundV3UsdceComet = 0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA; + address public compoundV3Rewards = 0x88730d254A2f7e6AC8388c3198aFd694bA9f7fae; +}