diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6c12e5b --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +PRIVATE_KEY= +ETHERSCAN_API_KEY= +OP_SEPOLIA_RPC= \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index bffd2f5..16f262f 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,4 +5,4 @@ libs = ["lib"] [rpc_endpoints] mainnet = "${MAINNET_RPC_URL}" - +op_sepolia = "${OP_SEPOLIA_RPC_URL}" diff --git a/script/DeployPendleTokens.s.sol b/script/DeployPendleTokens.s.sol index a229bca..0f23213 100644 --- a/script/DeployPendleTokens.s.sol +++ b/script/DeployPendleTokens.s.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.13; import {Script, console2} from "forge-std/Script.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; import {PendleERC20SY} from "pendle/core/StandardizedYield/implementations/PendleERC20SY.sol"; import {SYBase} from "pendle/core/StandardizedYield/SYBase.sol"; import {IStandardizedYield} from "pendle/interfaces/IStandardizedYield.sol"; import {PendleYieldContractFactoryV2} from "pendle/core/YieldContractsV2/PendleYieldContractFactoryV2.sol"; import {PendleYieldTokenV2} from "pendle/core/YieldContractsV2/PendleYieldTokenV2.sol"; - -address constant WETH_ADDRESS = address(0); +import {BaseSplitCodeFactory} from "pendle/core/libraries/BaseSplitCodeFactory.sol"; contract DeployPendleTokens is Script { function setUp() public {} @@ -19,6 +19,9 @@ contract DeployPendleTokens is Script { uint256 pk = vm.envUint(ENV_PRIVATE_KEY); vm.startBroadcast(pk); address sender = vm.addr(pk); + uint32 _expiry = 1_717_214_400; + + address wstETH = address(new MockERC20("Wrapped stETH", "wstETH", 18)); // Mint some tokens to the deployer MockERC20(wstETH).mint(sender, 1_000_000 ether); diff --git a/script/DeployPool.s.sol b/script/DeployPool.s.sol new file mode 100644 index 0000000..822aac4 --- /dev/null +++ b/script/DeployPool.s.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Script, console2} from "forge-std/Script.sol"; +import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol"; +import {PendleERC20SY} from "pendle/core/StandardizedYield/implementations/PendleERC20SY.sol"; +import {SYBase} from "pendle/core/StandardizedYield/SYBase.sol"; +import {IStandardizedYield} from "pendle/interfaces/IStandardizedYield.sol"; +import {PendleYieldContractFactoryV2} from "pendle/core/YieldContractsV2/PendleYieldContractFactoryV2.sol"; +import {PendleYieldTokenV2} from "pendle/core/YieldContractsV2/PendleYieldTokenV2.sol"; +import {BaseSplitCodeFactory} from "pendle/core/libraries/BaseSplitCodeFactory.sol"; +import {RMM} from "../src/RMM.sol"; +import {ERC20} from "solmate/tokens/ERC20.sol"; + +contract DeployPool is Script { + function setUp() public {} + + string public constant ENV_PRIVATE_KEY = "PRIVATE_KEY"; + address payable public constant RMM_ADDRESS = payable(address(0)); + address public constant SY_ADDRESS = address(0); + address public constant PT_ADDRESS = address(0); + uint256 public constant startPrice = 1 ether; + uint256 public constant initialDepositX = 1 ether; + uint256 public constant strike = 1 ether; + uint256 public constant sigma = 1 ether; + uint256 public constant tau = 365 days; + uint256 public constant fee = 0; + address public constant curator = address(0); + + function run() public { + uint256 pk = vm.envUint(ENV_PRIVATE_KEY); + address sender = vm.addr(pk); + vm.startBroadcast(pk); + + require(RMM_ADDRESS != address(0), "RMM_ADDRESS not set"); + require(SY_ADDRESS != address(0), "SY_ADDRESS not set"); + require(PT_ADDRESS != address(0), "PT_ADDRESS not set"); + + uint256 maturity = tau + block.timestamp; + + (uint256 initialLiquidity, uint256 initialDepositY) = RMM(RMM_ADDRESS).prepareInit({ + priceX: startPrice, + amountX: initialDepositX, + strike_: strike, + sigma_: sigma, + maturity_: maturity + }); + + if (ERC20(SY_ADDRESS).allowance(msg.sender, address(this)) < initialDepositX) { + ERC20(SY_ADDRESS).approve(RMM_ADDRESS, initialDepositX); + } + + if (ERC20(PT_ADDRESS).allowance(msg.sender, address(this)) < initialDepositY) { + ERC20(PT_ADDRESS).approve(RMM_ADDRESS, initialDepositY); + } + + RMM(RMM_ADDRESS).init({ + tokenX_: SY_ADDRESS, + tokenY_: PT_ADDRESS, + priceX: startPrice, + amountX: initialDepositX, + strike_: strike, + sigma_: sigma, + fee_: fee, + maturity_: maturity, + curator_: curator + }); + + uint256 balance = ERC20(RMM_ADDRESS).balanceOf(sender); + console2.log("RMM LPT balance: ", balance); + + vm.stopBroadcast(); + } +}