Skip to content

Commit

Permalink
deploy scripts for rmm pendle tokens and pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexangelj committed May 7, 2024
1 parent 93b43ab commit 44fae61
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PRIVATE_KEY=
ETHERSCAN_API_KEY=
OP_SEPOLIA_RPC=
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ libs = ["lib"]

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"

op_sepolia = "${OP_SEPOLIA_RPC_URL}"
7 changes: 5 additions & 2 deletions script/DeployPendleTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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);
Expand Down
74 changes: 74 additions & 0 deletions script/DeployPool.s.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 44fae61

Please sign in to comment.