Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zmanian committed Jun 12, 2024
2 parents 49aee32 + e939808 commit 49d01f5
Show file tree
Hide file tree
Showing 62 changed files with 6,595 additions and 595 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"solidity.compileUsingRemoteVersion": "v0.8.16",
"search.exclude": { "lib": true },
"editor.formatOnSave": true,
"solidity.formatter": "prettier",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
}
"editor.defaultFormatter": "JuanBlanco.solidity"
},
"solidity.formatter": "forge",
}
37 changes: 33 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,37 @@
# This overrides the `auto_detect_solc` value
solc_version = '0.8.21'
auto_detect_solc = false

evm_version = 'shanghai'
# eth_rpc_url = "YOUR_ALCHEMY_HTTPS_URL_HERE"
# etherscan_api_key = "YOUR_ETHERSCAN_API_KEY_HERE"
block_number = 16869780
optimizer = true
optimizer_runs = 200

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
polygon = "${MATIC_RPC_URL}"
bsc = "${BNB_RPC_URL}"
avalanche = "${AVALANCHE_RPC_URL}"
arbitrum = "${ARBITRUM_RPC_URL}"
optimism = "${OPTIMISM_RPC_URL}"
base = "${BASE_RPC_URL}"
scroll = "${SCROLL_RPC_URL}"

# [etherscan]
# mainnet = { key = "${ETHERSCAN_KEY}", url = "https://api.etherscan.io/api" }
# polygon = { key = "${POLYGONSCAN_KEY}" }
# bsc = { key = "${BSCSCAN_KEY}" }
# avalanche = { key = "${SNOWTRACE_KEY}" }
# arbitrum = { key = "${ARBISCAN_KEY}" }
# optimism = { key = "${OPTIMISMSCAN_KEY}" }
# base = { key = "${BASESCAN_KEY}" }

[fmt]
FOUNDRY_FMT_LINE_LENGTH = 120
FOUNDRY_FMT_TAB_WIDTH = 4
FOUNDRY_FMT_BRACKET_SPACING = true
FOUNDRY_FMT_INT_TYPES = "long"
FOUNDRY_FMT_MULTILINE_FUNC_HEADER = "attributes_first"
FOUNDRY_FMT_QUOTE_STYLE = "double"
FOUNDRY_FMT_NUMBER_UNDERSCORE = "thousands"
FOUNDRY_FMT_OVERRIDE_SPACING = true
FOUNDRY_FMT_WRAP_COMMENTS = false
FOUNDRY_FMT_IGNORE = []
2 changes: 1 addition & 1 deletion lib/pendle-core-v2-public
3 changes: 2 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ ds-test/=lib/forge-std/lib/ds-test/src/
@uniswapV3P=lib/v3-periphery/contracts/
@uniswapV3C=lib/v3-core/contracts/
@balancer=lib/balancer-v2-monorepo/pkg
@ccip=lib/ccip/
@ccip=lib/ccip/
@pendle=lib/pendle-core-v2-public/
88 changes: 88 additions & 0 deletions resources/ContractDeploymentNames.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

contract ContractDeploymentNames {
// Infrastructure
string public registryName = "Registry V0.0";
string public priceRouterName = "PriceRouter V0.1";
string public timelockOwnerName = "Timelock Owner V0.0";
string public protocolFeeCollectorName = "Protocol Fee Collector V0.0";
string public feesAndReservesName = "Fees And Reserves V0.0";
string public withdrawQueueName = "Withdraw Queue V0.0";
string public simpleSolverName = "Simple Solver V0.0";
string public atomicQueueName = "Atomic Queue V0.0";
string public incentiveDistributorName = "Incentive Distributor V0.1";
// Adaptors
string public erc20AdaptorName = "ERC20 Adaptor V0.0";
string public erc4626AdaptorName = "ERC4626 Adaptor V0.0";
string public oneInchAdaptorName = "1Inch Adaptor V0.0";
string public zeroXAdaptorName = "0x Adaptor V0.0";
string public uniswapV3AdaptorName = "Uniswap V3 Adaptor V0.0";
string public uniswapV3PositionTrackerName = "Uniswap V3 Position Tracker V0.0";
string public swapWithUniswapAdaptorName = "Swap With Uniswap Adaptor V0.0";
string public aaveV3ATokenAdaptorName = "Aave V3 AToken Adaptor V0.0";
string public aaveV3DebtTokenAdaptorName = "Aave V3 Debt Token Adaptor V0.0";
string public compoundV3SupplyAdaptorName = "Compound V3 Supply Adaptor V 0.0";
string public compoundV3RewardsAdaptorName = "Compound V3 Rewards Adaptor V 0.0";
string public feesAndReservesAdaptorName = "Fees And Reserves Adaptor V 0.0";
string public balancerPoolAdaptorName = "Balancer Pool Adaptor V 0.0";
// Deploy below only after it has been confirmed that they will work on L2
string public balancerV2PoolAdaptorName = "Balancer Pool Adaptor V 0.0";
string public auraAdaptorName = "Aura ERC4626 Adaptor V 0.0";
string public curveAdaptorName = "Curve Adaptor V 0.0";
string public convexCurveAdaptorName = "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",
// }
}
52 changes: 52 additions & 0 deletions resources/PositionIds.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

contract PositionIds {
uint32 public constant ERC20_USDC_POSITION = 1;
uint32 public constant ERC20_USDCE_POSITION = 2;
uint32 public constant ERC20_DAI_POSITION = 3;
uint32 public constant ERC20_USDT_POSITION = 4;
uint32 public constant ERC20_LUSD_POSITION = 5;
uint32 public constant ERC20_FRAX_POSITION = 6;
uint32 public constant ERC20_WETH_POSITION = 7;
uint32 public constant ERC20_WSTETH_POSITION = 8;
uint32 public constant ERC20_RETH_POSITION = 9;
uint32 public constant AAVE_V3_LOW_HF_A_USDC_POSITION = 10;
uint32 public constant AAVE_V3_LOW_HF_A_USDCE_POSITION = 11;
uint32 public constant AAVE_V3_LOW_HF_A_DAI_POSITION = 12;
uint32 public constant AAVE_V3_LOW_HF_A_USDT_POSITION = 13;
uint32 public constant AAVE_V3_LOW_HF_A_LUSD_POSITION = 14;
uint32 public constant AAVE_V3_LOW_HF_A_FRAX_POSITION = 15;
uint32 public constant AAVE_V3_LOW_HF_A_WETH_POSITION = 16;
uint32 public constant AAVE_V3_LOW_HF_A_WSTETH_POSITION = 17;
uint32 public constant AAVE_V3_LOW_HF_A_RETH_POSITION = 18;
uint32 public constant AAVE_V3_LOW_HF_DEBT_USDC_POSITION = 19;
uint32 public constant AAVE_V3_LOW_HF_DEBT_USDCE_POSITION = 20;
uint32 public constant AAVE_V3_LOW_HF_DEBT_DAI_POSITION = 21;
uint32 public constant AAVE_V3_LOW_HF_DEBT_USDT_POSITION = 22;
uint32 public constant AAVE_V3_LOW_HF_DEBT_LUSD_POSITION = 23;
uint32 public constant AAVE_V3_LOW_HF_DEBT_FRAX_POSITION = 24;
uint32 public constant AAVE_V3_LOW_HF_DEBT_WETH_POSITION = 25;
uint32 public constant AAVE_V3_LOW_HF_DEBT_WSTETH_POSITION = 26;
uint32 public constant AAVE_V3_LOW_HF_DEBT_RETH_POSITION = 27;
uint32 public constant UNISWAP_V3_USDC_USDCE_POSITION = 28;
uint32 public constant UNISWAP_V3_USDC_DAI_POSITION = 29;
uint32 public constant UNISWAP_V3_USDC_USDT_POSITION = 30;
uint32 public constant UNISWAP_V3_USDC_LUSD_POSITION = 31;
uint32 public constant UNISWAP_V3_USDC_FRAX_POSITION = 32;
uint32 public constant UNISWAP_V3_USDCE_DAI_POSITION = 33;
uint32 public constant UNISWAP_V3_USDCE_USDT_POSITION = 34;
uint32 public constant UNISWAP_V3_USDCE_LUSD_POSITION = 35;
uint32 public constant UNISWAP_V3_USDCE_FRAX_POSITION = 36;
uint32 public constant UNISWAP_V3_DAI_USDT_POSITION = 37;
uint32 public constant UNISWAP_V3_DAI_LUSD_POSITION = 38;
uint32 public constant UNISWAP_V3_DAI_FRAX_POSITION = 39;
uint32 public constant UNISWAP_V3_USDT_LUSD_POSITION = 40;
uint32 public constant UNISWAP_V3_USDT_FRAX_POSITION = 41;
uint32 public constant UNISWAP_V3_LUSD_FRAX_POSITION = 42;
uint32 public constant UNISWAP_V3_WETH_WSTETH_POSITION = 43;
uint32 public constant UNISWAP_V3_WETH_RETH_POSITION = 44;
uint32 public constant UNISWAP_V3_WSTETH_RETH_POSITION = 45;
uint32 public constant COMPOUND_V3_SUPPLY_USDC_POSITION = 46;
uint32 public constant COMPOUND_V3_SUPPLY_USDCE_POSITION = 47;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// 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 {ArbitrumAddresses} from "test/resources/Arbitrum/ArbitrumAddresses.sol";
import {ContractDeploymentNames} from "resources/ContractDeploymentNames.sol";
import {SafeTransferLib} from "@solmate/utils/SafeTransferLib.sol";
import {ERC20} from "@solmate/tokens/ERC20.sol";
import {CellarStaking} from "src/modules/staking/CellarStaking.sol";

import {CellarWithOracleWithBalancerFlashLoansWithMultiAssetDeposit} from
"src/base/permutations/advanced/CellarWithOracleWithBalancerFlashLoansWithMultiAssetDeposit.sol";
import {CellarWithOracleWithBalancerFlashLoansWithMultiAssetDepositWithNativeSupport} from
"src/base/permutations/advanced/CellarWithOracleWithBalancerFlashLoansWithMultiAssetDepositWithNativeSupport.sol";
import {ERC4626SharePriceOracle} from "src/base/ERC4626SharePriceOracle.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/production/AddCompoundV3SupplyAndDeployStakingContractsForRYProducts.s.sol:AddCompoundV3SupplyAndDeployStakingContractsForRYProductsScript --evm-version london --with-gas-price 100000000 --slow --broadcast --etherscan-api-key $ARBISCAN_KEY --verify
* If you need to verify contracts after deployment run the following command
* source .env && forge script script/Arbitrum/production/AddCompoundV3SupplyAndDeployStakingContractsForRYProducts.s.sol:AddCompoundV3SupplyAndDeployStakingContractsForRYProductsScript --evm-version london --etherscan-api-key $ARBISCAN_KEY --verify --resume --rpc-url $ARBITRUM_RPC_URL
* @dev Optionally can change `--with-gas-price` to something more reasonable
*/
contract AddCompoundV3SupplyAndDeployStakingContractsForRYProductsScript is
Script,
ArbitrumAddresses,
ContractDeploymentNames,
PositionIds
{
using SafeTransferLib for ERC20;
using Math for uint256;
using stdJson for string;

address public cellarOwner = dev0Address;
uint256 public privateKey;
Deployer public deployer = Deployer(deployerAddress);
Registry public registry;
PriceRouter public priceRouter;
address public compoundV3SupplyAdaptor;
address public compoundV3RewardsAdaptor;

CellarWithOracleWithBalancerFlashLoansWithMultiAssetDeposit public RYUSD;
CellarWithOracleWithBalancerFlashLoansWithMultiAssetDepositWithNativeSupport public RYE;

function setUp() external {
privateKey = vm.envUint("PRIVATE_KEY");
vm.createSelectFork("arbitrum");
registry = Registry(deployer.getAddress(registryName));
priceRouter = PriceRouter(deployer.getAddress(priceRouterName));
compoundV3SupplyAdaptor = deployer.getAddress(compoundV3SupplyAdaptorName);
compoundV3RewardsAdaptor = deployer.getAddress(compoundV3RewardsAdaptorName);
RYUSD = CellarWithOracleWithBalancerFlashLoansWithMultiAssetDeposit(deployer.getAddress(realYieldUsdName));
RYE = CellarWithOracleWithBalancerFlashLoansWithMultiAssetDepositWithNativeSupport(
payable(deployer.getAddress(realYieldEthName))
);
}

function run() external {
vm.startBroadcast(privateKey);

// Setup Compound V3 in RYUSD.
RYUSD.addAdaptorToCatalogue(compoundV3SupplyAdaptor);
RYUSD.addAdaptorToCatalogue(compoundV3RewardsAdaptor);
RYUSD.addPositionToCatalogue(COMPOUND_V3_SUPPLY_USDC_POSITION);
RYUSD.addPositionToCatalogue(COMPOUND_V3_SUPPLY_USDCE_POSITION);

// Deploy staking adaptors.
_createStakingContract(RYUSD, realYieldUsdStakingName);
_createStakingContract(RYE, realYieldEthStakingName);

vm.stopBroadcast();
}

function _createStakingContract(ERC20 _stakingToken, string memory _name) internal returns (CellarStaking) {
bytes memory creationCode;
bytes memory constructorArgs;

address _owner = devStrategist;
ERC20 _distributionToken = AXL_SOMM;
uint256 _epochDuration = 3 days;
uint256 shortBoost = 0.1e18;
uint256 mediumBoost = 0.3e18;
uint256 longBoost = 0.5e18;
uint256 shortBoostTime = 7 days;
uint256 mediumBoostTime = 14 days;
uint256 longBoostTime = 21 days;

// Deploy the staking contract.
creationCode = type(CellarStaking).creationCode;
constructorArgs = abi.encode(
_owner,
_stakingToken,
_distributionToken,
_epochDuration,
shortBoost,
mediumBoost,
longBoost,
shortBoostTime,
mediumBoostTime,
longBoostTime
);
return CellarStaking(deployer.deployContract(_name, creationCode, constructorArgs, 0));
}
}
35 changes: 35 additions & 0 deletions script/Arbitrum/production/DeployAtomicQueueSolver.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import {Deployer} from "src/Deployer.sol";
import {AtomicSolverV2} from "src/modules/atomic-queue/AtomicSolverV2.sol";
import {ArbitrumAddresses} from "test/resources/Arbitrum/ArbitrumAddresses.sol";

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";

/**
* source .env && forge script script/Arbitrum/production/DeployAtomicQueueSolver.s.sol:DeployAtomicQueueSolverScript --evm-version london --with-gas-price 100000000 --slow --broadcast
* @dev Optionally can change `--with-gas-price` to something more reasonable
*/
contract DeployAtomicQueueSolverScript is Script, ArbitrumAddresses {
uint256 public privateKey;
Deployer public deployer = Deployer(deployerAddress);

function setUp() external {
privateKey = vm.envUint("PRIVATE_KEY");
vm.createSelectFork("arbitrum");
}

function run() external {
bytes memory creationCode;
bytes memory constructorArgs;
vm.startBroadcast(privateKey);

creationCode = type(AtomicSolverV2).creationCode;
constructorArgs = abi.encode(devStrategist, vault);
deployer.deployContract("Nothing to see here V 0.0", creationCode, constructorArgs, 0);

vm.stopBroadcast();
}
}
28 changes: 28 additions & 0 deletions script/Arbitrum/production/DeployAxelarProxy.s copy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { AxelarProxy } from "src/AxelarProxy.sol";
import { Deployer } from "src/Deployer.sol";

import { ArbitrumAddresses } from "test/resources/Arbitrum/ArbitrumAddresses.sol";

import "forge-std/Script.sol";

/**
* @dev Run
* `source .env && forge script script/Arbitrum/production/DeployAxelarProxy.s.sol:DeployAxelarProxyScript --evm-version london --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY —optimize —optimizer-runs 200 --with-gas-price 100000000 --verify --etherscan-api-key $ARBISCAN_KEY --slow --broadcast`
* @dev Optionally can change `--with-gas-price` to something more reasonable
*/
contract DeployAxelarProxyScript is Script, ArbitrumAddresses {
Deployer public deployer = Deployer(deployerAddress);

function run() external {
string memory name = "Axelar Proxy V0.0";
bytes memory creationCode = type(AxelarProxy).creationCode;
bytes memory constructorArgs = abi.encode(axelarGateway, axelarSommelierSender);

vm.startBroadcast();
deployer.deployContract(name, creationCode, constructorArgs, 0);
vm.stopBroadcast();
}
}
Loading

0 comments on commit 49d01f5

Please sign in to comment.