Skip to content

Commit 55e9926

Browse files
committed
sei testnet
1 parent 0ca8f95 commit 55e9926

13 files changed

Lines changed: 473 additions & 211 deletions

script/ClaimMulti.s.sol

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// SPDX-License-Identifier: MIT
2+
//
3+
// _____ _ _
4+
// |_ _| | | (_)
5+
// | | ___ _ __ __| | ___ _ __ _ _______
6+
// | |/ _ \ '_ \ / _` |/ _ \ '__| |_ / _ \
7+
// | | __/ | | | (_| | __/ | | |/ / __/
8+
// \_/\___|_| |_|\__,_|\___|_| |_/___\___|
9+
//
10+
// Copyright (c) Tenderize Labs Ltd
11+
12+
// solhint-disable no-console
13+
14+
pragma solidity 0.8.25;
15+
16+
import { Script, console2 } from "forge-std/Script.sol";
17+
18+
import { MultiValidatorLST } from "core/multi-validator/MultiValidatorLST.sol";
19+
import { MultiValidatorFactory } from "core/multi-validator/Factory.sol";
20+
import { FlashUnstake, TenderSwap } from "core/multi-validator/FlashUnstake.sol";
21+
import { Tenderizer } from "core/tenderize-v3/Tenderizer.sol";
22+
import { LPT } from "core/adapters/LivepeerAdapter.sol";
23+
import { GRT } from "core/adapters/GraphAdapter.sol";
24+
import { GraphAdapter } from "core/adapters/GraphAdapter.sol";
25+
import { Registry } from "core/registry/Registry.sol";
26+
27+
import { ERC1967Proxy } from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.sol";
28+
import { MockERC20 } from "solmate/test/utils/mocks/MockERC20.sol";
29+
import { FlashUnstake } from "core/multi-validator/FlashUnstake.sol";
30+
31+
import { SeiAdapter } from "core/tenderize-v3/Sei/SeiAdapter.sol";
32+
import { ISeiStaking, Delegation } from "core/tenderize-v3/Sei/Sei.sol";
33+
34+
address constant TENDERIZER_1 = 0x4b7339E599a599DBd7829a8ECA0d233ED4F7eA09;
35+
address constant TENDERIZER_2 = 0xFB32bF22B4F004a088c1E7d69e29492f5D7CD7E1;
36+
address constant TENDERIZER_3 = 0x6DFd5Cee0Ed2ec24Fdc814Ad857902DE01c065d6;
37+
address constant LIVEPEER_MINTER = 0xc20DE37170B45774e6CD3d2304017fc962f27252;
38+
39+
import { MultiValidatorLST } from "core/multi-validator/MultiValidatorLST.sol";
40+
41+
contract MultiValidatorLST_Deploy is Script {
42+
bytes32 private constant salt = bytes32(uint256(1));
43+
44+
MultiValidatorFactory factory;
45+
// MultiValidatorLST lst;
46+
47+
function run() public {
48+
uint256 privKey = vm.envUint("PRIVATE_KEY");
49+
// address owner = 0xc1cFab553835D74717c4499793EEa6Ef198A3031;
50+
// vm.startBroadcast(owner);
51+
52+
// Registry(0xa7cA8732Be369CaEaE8C230537Fc8EF82a3387EE).registerAdapter(address(GRT), address(new GraphAdapter()));
53+
// vm.stopBroadcast();
54+
// address guy = 0x838afC2DE97D97A1ab478A8297292482A278A9CA;
55+
// address lst = 0x4003E23bE46f3Bf2B50c3c7F8B13aAeCDc71EA72;
56+
// vm.startBroadcast(guy);
57+
// // console2.log("unlock maturity", Tenderizer(payable(lst)).unlockMaturity(4));
58+
// Tenderizer(payable(lst)).withdraw(guy, 116);
59+
60+
// vm.stopBroadcast();
61+
62+
// livepeer 0x388b0faf9de300ffc21e3dc849202544901792cb
63+
// graph 0x9f5540f4a9777ea678d80a7b508dcd924a4b1187
64+
vm.startBroadcast(privKey);
65+
66+
address lpt = 0x388B0fAf9DE300ffC21e3DC849202544901792CB;
67+
address grt = 0x9F5540F4A9777Ea678D80A7b508DcD924a4b1187;
68+
69+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(1);
70+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(2);
71+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(3);
72+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(4);
73+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(5);
74+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(6);
75+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(7);
76+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(8);
77+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(9);
78+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(10);
79+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(11);
80+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(12);
81+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(13);
82+
83+
for (uint24 i = 1; i <= 13; i++) {
84+
MultiValidatorLST(payable(grt)).claimValidatorRewards(i);
85+
MultiValidatorLST(payable(lpt)).claimValidatorRewards(i);
86+
}
87+
88+
vm.stopBroadcast();
89+
}
90+
}

script/Run.s.sol

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pragma solidity 0.8.25;
1515

1616
import { Script, console2 } from "forge-std/Script.sol";
1717

18-
import { MultiValidatorLST } from "core/multi-validator/MultiValidatorLST.sol";
18+
import { MultiValidatorLSTNative } from "core/tenderize-v3/multi-validator/MultiValidatorLST.sol";
1919
import { MultiValidatorFactory } from "core/multi-validator/Factory.sol";
2020
import { FlashUnstake, TenderSwap } from "core/multi-validator/FlashUnstake.sol";
2121
import { Tenderizer } from "core/tenderize-v3/Tenderizer.sol";
@@ -28,7 +28,7 @@ import { ERC1967Proxy } from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy.
2828
import { MockERC20 } from "solmate/test/utils/mocks/MockERC20.sol";
2929
import { FlashUnstake } from "core/multi-validator/FlashUnstake.sol";
3030

31-
import { SeiAdapter } from "core/tenderize-v3/Sei/SeiAdapter.sol";
31+
import { SeiAdapter, SEI } from "core/tenderize-v3/Sei/SeiAdapter.sol";
3232
import { ISeiStaking, Delegation } from "core/tenderize-v3/Sei/Sei.sol";
3333

3434
address constant TENDERIZER_1 = 0x4b7339E599a599DBd7829a8ECA0d233ED4F7eA09;
@@ -45,7 +45,7 @@ contract MultiValidatorLST_Deploy is Script {
4545
// MultiValidatorLST lst;
4646

4747
function run() public {
48-
// uint256 privKey = vm.envUint("PRIVATE_KEY");
48+
uint256 privKey = vm.envUint("PRIVATE_KEY");
4949
// address owner = 0xc1cFab553835D74717c4499793EEa6Ef198A3031;
5050
// vm.startBroadcast(owner);
5151

@@ -59,12 +59,34 @@ contract MultiValidatorLST_Deploy is Script {
5959

6060
// vm.stopBroadcast();
6161

62-
address lst = 0x9F5540F4A9777Ea678D80A7b508DcD924a4b1187;
63-
MultiValidatorLST(payable(lst)).stakingPools(0);
64-
MultiValidatorLST(payable(lst)).stakingPools(1);
65-
MultiValidatorLST(payable(lst)).stakingPools(2);
66-
MultiValidatorLST(payable(lst)).claimValidatorRewards(4);
67-
MultiValidatorLST(payable(lst)).claimValidatorRewards(5);
68-
MultiValidatorLST(payable(lst)).claimValidatorRewards(6);
62+
// livepeer 0x388b0faf9de300ffc21e3dc849202544901792cb
63+
// graph 0x9f5540f4a9777ea678d80a7b508dcd924a4b1187
64+
vm.startBroadcast(privKey);
65+
66+
// address lpt = 0x388B0fAf9DE300ffC21e3DC849202544901792CB;
67+
// address grt = 0x9F5540F4A9777Ea678D80A7b508DcD924a4b1187;
68+
69+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(1);
70+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(2);
71+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(3);
72+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(4);
73+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(5);
74+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(6);
75+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(7);
76+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(8);
77+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(9);
78+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(10);
79+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(11);
80+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(12);
81+
// MultiValidatorLST(payable(lpt)).claimValidatorRewards(13);
82+
83+
SeiAdapter adapter = new SeiAdapter();
84+
Registry(0x4EB2ce452ea35A050495c3c23193b385f48473C0).registerAdapter(address(SEI), address(adapter));
85+
86+
MultiValidatorLSTNative(payable(0x58CDD57FD0c878AF54eD0D9578959BA8FD154Aa7)).deposit{ value: 3 ether }(address(this));
87+
88+
vm.stopBroadcast();
6989
}
7090
}
91+
92+
// TODO: Add validator and check if we can deposit in it without a small dust deposit from EOA first

script/Tenderize_Native_Deploy.s.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ contract Tenderize_Native_Deploy is Script {
6666

6767
// 4. Initialize Registry
6868
Registry(registryProxy).initialize(address(tenderizerImpl), address(unlocks));
69+
Registry(registryProxy).setTreasury(address(payable(msg.sender)));
6970

7071
// 5. Deploy TenderizerFactory (UpgradeableBeacon) and register it
7172
TenderizerFactory factory = new TenderizerFactory(registryProxy, address(tenderizerImpl));

script/multi-validator/MultiUpgrade.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract MultiUpgrade is Script {
1414
function run() public {
1515
vm.startBroadcast();
1616

17-
address lst = address(new MultiValidatorLST{ salt: bytes32(uint256(2)) }(registry));
17+
address lst = address(new MultiValidatorLST{ salt: bytes32(uint256(3)) }(registry));
1818

1919
console2.log("Multi LST deployed at: %s", lst);
2020
}

script/multi-validator/MultiValidatorFactory.native.deploy.s.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,22 @@ contract MultiValidatorFactory_Deploy is Script {
4848
vm.stopBroadcast();
4949
}
5050
}
51+
52+
/*
53+
Registry Implementation: 0x4F1728d4aFE52a6B581FD139f47A56021cE09772
54+
Registry Proxy: 0x4EB2ce452ea35A050495c3c23193b385f48473C0
55+
Renderer Implementation: 0x185c39C27b4d55FB665c6f72734f13B67225114B
56+
Renderer Proxy: 0x79a8e10Ce1aA4eBAa00c469593aA550C0f11E6a2
57+
Unlocks: 0x5dDADBA4a7C5794441F2536b826a9660d9F93095
58+
Tenderizer Implementation: 0x61FCAF26fF11CE1b5b372E3Dae96640F0B932cEa
59+
Factory (Beacon): 0xf8292992Ac9cFa7524DA04C63E4d296A4a81C887
60+
61+
62+
63+
Deploying MultiValidatorFactory...
64+
MultiValidatorFactory deployed at: 0xe6c969743180BE1AdC8Fd8880DBEFef41412dae1
65+
FlashUnstake deployed at: 0xDEaa38CeA8048A7aaEC81F0081c0aA38A972BBB5
66+
67+
MultiValidator SEI deployed At: 0x58CDD57FD0c878AF54eD0D9578959BA8FD154Aa7
68+
69+
*/

script/multi-validator/MultiValidatorLST.native.deploy.s.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ contract MultiValidatorLST_Deploy is Script {
2323
bytes32 private constant salt = bytes32(uint256(1));
2424

2525
address[] tenderizers = [
26-
0x28D5bC07301472829bab14aC26CF74676e9FB1d3,
27-
0x9744581825e21C07F51B35BF3cC0AE9389a1Ca3C,
28-
0x131a09734AE656f78030b2a89687b4D58E2FbE62,
29-
0x9d68575fE6cA05E4D6F6d982fe6Dfac6678D243E
26+
0x0BA49e1b6616CCb0650B39043554ad791b1b6eD1,
27+
0xCF4cD036Ac6FAB8F6bd49C0890ed53a38767B62F,
28+
0x06fd675BE0513d4fF5F05796a3BAD9d20d91610B,
29+
0x82c72F3Aefc525ade379b6E71E23f71e8fe84aab
3030
];
3131

3232
MultiValidatorLSTNative lst;
3333

3434
function run() public {
3535
uint256 privKey = vm.envUint("PRIVATE_KEY");
36-
MultiValidatorFactory factory = MultiValidatorFactory(vm.envAddress("FACTORY"));
36+
MultiValidatorFactory factory = MultiValidatorFactory(0xe6c969743180BE1AdC8Fd8880DBEFef41412dae1);
3737
vm.startBroadcast(privKey);
3838

3939
console2.log("Deploying MultiValidatorLST...");

src/multi-validator/AVLTree.Sol

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,16 @@ function _insertRecursive(Tree storage tree, uint24 nodeId, uint24 newId, Node m
206206
_applyStatsAdd(tree, replDiv);
207207
// Remove stats for the current node being deleted
208208
_applyStatsRemove(tree, current.divergence);
209-
// Link replacement's children
210-
tree.nodes[replacementId].left = newLeft;
211-
tree.nodes[replacementId].right = current.right;
209+
210+
// Rehydrate replacement node (it was deleted in the subtree removal)
211+
{
212+
uint8 leftHeight = newLeft == 0 ? 0 : tree.nodes[newLeft].height;
213+
uint8 rightHeight = current.right == 0 ? 0 : tree.nodes[current.right].height;
214+
tree.nodes[replacementId].divergence = replDiv;
215+
tree.nodes[replacementId].left = newLeft;
216+
tree.nodes[replacementId].right = current.right;
217+
tree.nodes[replacementId].height = max(leftHeight, rightHeight) + 1;
218+
}
212219

213220
// Delete current node
214221
delete tree.nodes[nodeId];
@@ -262,9 +269,16 @@ function _insertRecursive(Tree storage tree, uint24 nodeId, uint24 newId, Node m
262269
int200 replDiv = tree.nodes[replacementId].divergence;
263270
// Remove replacement from left subtree (without stats update)
264271
uint24 newLeft = _removeByKeyForUpdate(tree, current.left, replDiv, replacementId);
265-
// Link replacement's children
266-
tree.nodes[replacementId].left = newLeft;
267-
tree.nodes[replacementId].right = current.right;
272+
273+
// Rehydrate replacement node (it was deleted in the subtree removal)
274+
{
275+
uint8 leftHeight = newLeft == 0 ? 0 : tree.nodes[newLeft].height;
276+
uint8 rightHeight = current.right == 0 ? 0 : tree.nodes[current.right].height;
277+
tree.nodes[replacementId].divergence = replDiv;
278+
tree.nodes[replacementId].left = newLeft;
279+
tree.nodes[replacementId].right = current.right;
280+
tree.nodes[replacementId].height = max(leftHeight, rightHeight) + 1;
281+
}
268282

269283
// Delete current node
270284
delete tree.nodes[nodeId];
@@ -696,10 +710,4 @@ function _insertRecursive(Tree storage tree, uint24 nodeId, uint24 newId, Node m
696710
return tree.last;
697711
}
698712

699-
/// @notice Returns the bounds of the tree (root, first, and last node IDs).
700-
/// @param tree The tree storage pointer.
701-
/// @return root The root node ID.
702-
/// @return first The node ID with the smallest divergence.
703-
/// @return last The node ID with the largest divergence.
704-
705713
}

0 commit comments

Comments
 (0)