Skip to content

Commit

Permalink
refactor: move script validation into separate test file
Browse files Browse the repository at this point in the history
  • Loading branch information
jparklev committed Nov 4, 2024
1 parent b1a59d4 commit 039ed65
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
19 changes: 2 additions & 17 deletions contracts/script/PointTokenVault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {MockERC20} from "solmate/test/utils/mocks/MockERC20.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {LibString} from "solady/utils/LibString.sol";

import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";

import {console} from "forge-std/console.sol";
Expand Down Expand Up @@ -118,7 +117,7 @@ contract PointTokenVaultScripts is BatchScript {
vm.stopBroadcast();
}

function setRedemptionENA30Oct24() public {
function setRedemptionENA4Nov24() public {
// Core contract and token setup
PointTokenVault vaultV0_1_0 = PointTokenVault(payable(0x1EeEBa76f211C4Dce994b9c5A74BDF25DB649Fa1));
bytes32 pointsId = LibString.packTwo("Rumpel kPoint: Ethena S2", "kpSATS");
Expand All @@ -133,22 +132,8 @@ contract PointTokenVaultScripts is BatchScript {

// Update merkle root
vm.startBroadcast(MAINNET_MERKLE_UPDATER);
vaultV0_1_0.updateRoot(0x602cdd6dd4f1c6f7bb049ce8b23a49e5177dc84830c7f00cc09eb0f11f03d9be);
vaultV0_1_0.updateRoot(0x50420fa89bbefa971ffb968dc2547a8b5db8061d62dd3794ccc975531a127292);
vm.stopBroadcast();

// Test redemption
bytes32[] memory proof = new bytes32[](5);
proof[0] = 0xc1a70bb7d5c4ddf647114cb36083bca867a80e37e187aa1d6705f3b12357d7cf;
proof[1] = 0x04a635b0e5b8e5ac70059fb9dc2682f5102a3b4a2f8b2c0d6f1ea43b1e04272f;
proof[2] = 0xab802966e4277e85c878dad4c849c7632735a56c3710c197470de81707286069;
proof[3] = 0x7c0bd8bd630d01f1a459f6cd963cfc5f58487dec582339b1d8f29edbbd41d8ab;
proof[4] = 0x0fe239692610c805880a540ea359a0f3f8314f94bb95cd4ec53d712ae6cdc63d;

address testUser = 0x25E426b153e74Ab36b2685c3A464272De60888Ae;
uint256 claimAmount = 52792622186481736164;

vm.prank(testUser);
vaultV0_1_0.redeemRewards(PointTokenVault.Claim(pointsId, claimAmount, claimAmount, proof), testUser);
}

// Useful for emergencies, where we need to override both the current and previous root at once
Expand Down
59 changes: 59 additions & 0 deletions contracts/test/SetRedemptionENA4Nov24.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity =0.8.24;

import {Test} from "forge-std/Test.sol";
import {LibString} from "solady/utils/LibString.sol";
import {ERC20} from "solmate/test/utils/mocks/MockERC20.sol";

import {PointTokenVault} from "../PointTokenVault.sol";
import {PointTokenVaultScripts} from "../script/PointTokenVault.s.sol";

contract SetRedemptionENA4Nov24Test is Test {
PointTokenVault vaultV0_1_0 = PointTokenVault(payable(0x1EeEBa76f211C4Dce994b9c5A74BDF25DB649Fa1));
bytes32 pointsId = LibString.packTwo("Rumpel kPoint: Ethena S2", "kpSATS");

function setUp() public {
string memory MAINNET_RPC_URL = vm.envString("MAINNET_RPC_URL");
uint256 forkId = vm.createFork(MAINNET_RPC_URL, 21_112_610); // Block mined at Nov-04-2024 06:51:59 AM +UTC
vm.selectFork(forkId);

PointTokenVaultScripts scripts = new PointTokenVaultScripts();
scripts.setRedemptionENA4Nov24();
}

function test_RedemptionRights1() public {
bytes32[] memory proof = new bytes32[](5);
proof[0] = 0x991fd8976022911aeb40e40bcb5754f9529f2080710f7ec1db8ace85c4f7b7f8;
proof[1] = 0xc6f15a7cbd986873c6b761e81c98ee8ac4afd1c9885b7d8e0ae4de752040ab12;
proof[2] = 0xca808b743099c608cd9b81872c528c521d76505c116bedabfdcc6307c9c92bfb;
proof[3] = 0x703f21e968e8791afb70bcf780821f479ea90632b109016d8b24c8637771383c;
proof[4] = 0x0f76084b6c6777c64b0f591ee64d8c66c54c0bdeb5ce44142823c0f74b856267;

address USER = 0x25E426b153e74Ab36b2685c3A464272De60888Ae;
uint256 AMOUNT = 52792622186481736164;

vm.prank(USER);
vaultV0_1_0.redeemRewards(PointTokenVault.Claim(pointsId, AMOUNT, AMOUNT, proof), USER);
}

function test_NormalPTokenClaim() public {
bytes32[] memory proof = new bytes32[](5);
proof[0] = 0x8b788cab342842ae529d8efac9659e1af9367270c13caaf4c8b5ef4c67a51402;
proof[1] = 0xfaca43636023a73bf06295aa693c262efe0bb3231357a68b8ad7eec7e901c8ef;
proof[2] = 0x2eec07dc470578d8beb2eb4edf89d2309714b87ea0b9e9b2f119df39a28278c7;
proof[3] = 0x703f21e968e8791afb70bcf780821f479ea90632b109016d8b24c8637771383c;
proof[4] = 0x0f76084b6c6777c64b0f591ee64d8c66c54c0bdeb5ce44142823c0f74b856267;

address USER = 0x24C694d193B19119bcDea9D40a3b0bfaFb281E6D;
uint256 AMOUNT = 152407798291890457882;

vm.prank(USER);
OldVault(address(vaultV0_1_0)).claimPTokens(PointTokenVault.Claim(pointsId, AMOUNT, AMOUNT, proof), USER);

assertEq(ERC20(address(vaultV0_1_0.pTokens(pointsId))).balanceOf(USER), AMOUNT);
}
}

interface OldVault {
function claimPTokens(PointTokenVault.Claim calldata claim, address account) external;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"address": "0xdFa21ceC8A46386F5d36F4b07E18BcCcA59f425B",
"blockNumber": "21105619",
"blockNumber": "21112349",
"balances": {
"0x25E426b153e74Ab36b2685c3A464272De60888Ae": "832939015897918484874",
"0xAF9e4E01525C4856E00Cb0F363AFc34E7decD6a7": "1209830694094345523934847",
Expand Down

0 comments on commit 039ed65

Please sign in to comment.