Skip to content

Commit

Permalink
chore: rename lidosplit => obollidosplit
Browse files Browse the repository at this point in the history
  • Loading branch information
samparsky committed Oct 9, 2023
1 parent f2690f9 commit fd244a0
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 54 deletions.
6 changes: 3 additions & 3 deletions docs/audit/LidoSplit.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Source Units in Scope: **`1`** (**100%**)

| Type | File | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex. Score | Capabilities |
| ---- | ------ | --------------- | ---------- | ----- | ------ | ----- | ------------- | -------------- | ------------ |
| 📝🔍 | src/lido/LidoSplit.sol | 1 | 1 | 72 | 64 | 29 | 31 | 34 | **** |
| 📝🔍 | src/lido/ObolLidoSplit.sol | 1 | 1 | 72 | 64 | 29 | 31 | 34 | **** |
| 📝🔍 | **Totals** | **1** | **1** | **72** | **64** | **29** | **31** | **34** | **** |

<sub>
Expand Down Expand Up @@ -237,7 +237,7 @@ This section lists functions that are explicitly declared public or payable. Ple

| File Name | SHA-1 Hash |
|-------------|--------------|
| src/lido/LidoSplit.sol | a6d06d355c3e9abd9b6674b54a0b9b9960d3da33 |
| src/lido/ObolLidoSplit.sol | a6d06d355c3e9abd9b6674b54a0b9b9960d3da33 |


Contracts Description Table
Expand All @@ -250,7 +250,7 @@ This section lists functions that are explicitly declared public or payable. Ple
| **IwSTETH** | Interface | |||
|| wrap | External ❗️ | 🛑 |NO❗️ |
||||||
| **LidoSplit** | Implementation | Clone |||
| **ObolLidoSplit** | Implementation | Clone |||
|| <Constructor> | Public ❗️ | 🛑 |NO❗️ |
|| splitWallet | Public ❗️ | |NO❗️ |
|| stETHAddress | Public ❗️ | |NO❗️ |
Expand Down
8 changes: 4 additions & 4 deletions docs/audit/LidoSplitFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Source Units in Scope: **`1`** (**100%**)

| Type | File | Logic Contracts | Interfaces | Lines | nLines | nSLOC | Comment Lines | Complex. Score | Capabilities |
| ---- | ------ | --------------- | ---------- | ----- | ------ | ----- | ------------- | -------------- | ------------ |
| 📝 | src/lido/LidoSplitFactory.sol | 1 | **** | 73 | 73 | 31 | 25 | 24 | **<abbr title='create/create2'>🌀</abbr>** |
| 📝 | src/lido/ObolLidoSplitFactory.sol | 1 | **** | 73 | 73 | 31 | 25 | 24 | **<abbr title='create/create2'>🌀</abbr>** |
| 📝 | **Totals** | **1** | **** | **73** | **73** | **31** | **25** | **24** | **<abbr title='create/create2'>🌀</abbr>** |

<sub>
Expand Down Expand Up @@ -166,7 +166,7 @@ This section lists functions that are explicitly declared public or payable. Ple

| 📤 Transfers ETH | ⚡ Low-Level Calls | 👥 DelegateCall | 🧮 Uses Hash Functions | 🔖 ECRecover | 🌀 New/Create/Create2 |
| ---------------- | ----------------- | --------------- | ---------------------- | ------------ | --------------------- |
| **** | **** | **** | **** | **** | `yes`<br>→ `NewContract:LidoSplit` |
| **** | **** | **** | **** | **** | `yes`<br>→ `NewContract:ObolLidoSplit` |

| ♻️ TryCatch | Σ Unchecked |
| ---------- | ----------- |
Expand Down Expand Up @@ -236,7 +236,7 @@ This section lists functions that are explicitly declared public or payable. Ple

| File Name | SHA-1 Hash |
|-------------|--------------|
| src/lido/LidoSplitFactory.sol | fbe7fc44155c90479b3d1c3f46886b2e67f0d5c0 |
| src/lido/ObolLidoSplitFactory.sol | fbe7fc44155c90479b3d1c3f46886b2e67f0d5c0 |


Contracts Description Table
Expand All @@ -246,7 +246,7 @@ This section lists functions that are explicitly declared public or payable. Ple
|:----------:|:-------------------:|:----------------:|:----------------:|:---------------:|
|| **Function Name** | **Visibility** | **Mutability** | **Modifiers** |
||||||
| **LidoSplitFactory** | Implementation | |||
| **ObolLidoSplitFactory** | Implementation | |||
|| <Constructor> | Public ❗️ | 🛑 |NO❗️ |
|| createSplit | External ❗️ | 🛑 |NO❗️ |

Expand Down
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ remappings = [
'solady/=lib/solady/src/',
]
solc_version = '0.8.19'
gas_reports = ["*"]


[rpc_endpoints]
Expand All @@ -27,4 +28,4 @@ tab_width = 2
wrap_comments = true

[fuzz]
runs = 1000
runs = 10
4 changes: 2 additions & 2 deletions src/lido/LidoSplit.sol → src/lido/ObolLidoSplit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {Clone} from "solady/utils/Clone.sol";
import {IwstETH} from "src/interfaces/IwstETH.sol";

/// @title LidoSplit
/// @title ObolLidoSplit
/// @author Obol
/// @notice A wrapper for 0xsplits/split-contracts SplitWallet that transforms
/// stETH token to wstETH token because stETH is a rebasing token
/// @dev Wraps stETH to wstETH and transfers to defined SplitWallet address
contract LidoSplit is Clone {
contract ObolLidoSplit is Clone {
error Invalid_Address();
error Invalid_FeeShare(uint256 fee);
error Invalid_FeeRecipient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pragma solidity 0.8.19;

import {LibClone} from "solady/utils/LibClone.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import "./LidoSplit.sol";
import "./ObolLidoSplit.sol";

/// @title LidoSplitFactory
/// @title ObolLidoSplitFactory
/// @author Obol
/// @notice A factory contract for cheaply deploying LidoSplit.
/// @notice A factory contract for cheaply deploying ObolLidoSplit.
/// @dev The address returned should be used to as reward address for Lido
contract LidoSplitFactory {
contract ObolLidoSplitFactory {
/// -----------------------------------------------------------------------
/// errors
/// -----------------------------------------------------------------------
Expand All @@ -27,17 +27,17 @@ contract LidoSplitFactory {
/// -----------------------------------------------------------------------

/// Emitted after lido split
event CreateLidoSplit(address split);
event CreateObolLidoSplit(address split);

/// -----------------------------------------------------------------------
/// storage
/// -----------------------------------------------------------------------

/// @dev lido split implementation
LidoSplit public immutable lidoSplitImpl;
ObolLidoSplit public immutable lidoSplitImpl;

constructor(address _feeRecipient, uint256 _feeShare, ERC20 _stETH, ERC20 _wstETH) {
lidoSplitImpl = new LidoSplit(_feeRecipient, _feeShare, _stETH, _wstETH);
lidoSplitImpl = new ObolLidoSplit(_feeRecipient, _feeShare, _stETH, _wstETH);
}

/// Creates a wrapper for splitWallet that transforms stETH token into
Expand All @@ -49,6 +49,6 @@ contract LidoSplitFactory {

lidoSplit = address(lidoSplitImpl).clone(abi.encodePacked(splitWallet));

emit CreateLidoSplit(lidoSplit);
emit CreateObolLidoSplit(lidoSplit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {LidoSplitFactory} from "src/lido/LidoSplitFactory.sol";
import {ObolLidoSplitFactory} from "src/lido/ObolLidoSplitFactory.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {LidoSplitTestHelper} from "./LidoSplitTestHelper.sol";
import {ObolLidoSplitTestHelper} from "./ObolLidoSplitTestHelper.sol";

contract LidoSplitFactoryTest is LidoSplitTestHelper, Test {
LidoSplitFactory internal lidoSplitFactory;
LidoSplitFactory internal lidoSplitFactoryWithFee;
contract ObolLidoSplitFactoryTest is ObolLidoSplitTestHelper, Test {
ObolLidoSplitFactory internal lidoSplitFactory;
ObolLidoSplitFactory internal lidoSplitFactoryWithFee;

address demoSplit;

event CreateLidoSplit(address split);
event CreateObolLidoSplit(address split);

function setUp() public {
uint256 mainnetBlock = 17_421_005;
vm.createSelectFork(getChain("mainnet").rpcUrl, mainnetBlock);

lidoSplitFactory = new LidoSplitFactory(
lidoSplitFactory = new ObolLidoSplitFactory(
address(0),
0,
ERC20(STETH_MAINNET_ADDRESS),
ERC20(WSTETH_MAINNET_ADDRESS)
);

lidoSplitFactoryWithFee = new LidoSplitFactory(
lidoSplitFactoryWithFee = new ObolLidoSplitFactory(
address(this),
1e3,
ERC20(STETH_MAINNET_ADDRESS),
Expand All @@ -37,21 +37,21 @@ contract LidoSplitFactoryTest is LidoSplitTestHelper, Test {

function testCan_CreateSplit() public {
vm.expectEmit(true, true, true, false, address(lidoSplitFactory));
emit CreateLidoSplit(address(0x1));
emit CreateObolLidoSplit(address(0x1));

lidoSplitFactory.createSplit(demoSplit);

vm.expectEmit(true, true, true, false, address(lidoSplitFactoryWithFee));
emit CreateLidoSplit(address(0x1));
emit CreateObolLidoSplit(address(0x1));

lidoSplitFactoryWithFee.createSplit(demoSplit);
}

function testCannot_CreateSplitInvalidAddress() public {
vm.expectRevert(LidoSplitFactory.Invalid_Wallet.selector);
vm.expectRevert(ObolLidoSplitFactory.Invalid_Wallet.selector);
lidoSplitFactory.createSplit(address(0));

vm.expectRevert(LidoSplitFactory.Invalid_Wallet.selector);
vm.expectRevert(ObolLidoSplitFactory.Invalid_Wallet.selector);
lidoSplitFactoryWithFee.createSplit(address(0));
}
}
49 changes: 33 additions & 16 deletions src/test/lido/LidoSplit.t.sol → src/test/lido/ObolLidoSplit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {LidoSplitFactory, LidoSplit, IwstETH} from "src/lido/LidoSplitFactory.sol";
import {ObolLidoSplitFactory, ObolLidoSplit, IwstETH} from "src/lido/ObolLidoSplitFactory.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {LidoSplitTestHelper} from "./LidoSplitTestHelper.sol";
import {ObolLidoSplitTestHelper} from "./ObolLidoSplitTestHelper.sol";
import {MockERC20} from "src/test/utils/mocks/MockERC20.sol";

contract LidoSplitTest is LidoSplitTestHelper, Test {
contract ObolLidoSplitTest is ObolLidoSplitTestHelper, Test {
uint256 internal constant PERCENTAGE_SCALE = 1e5;

LidoSplitFactory internal lidoSplitFactory;
LidoSplitFactory internal lidoSplitFactoryWithFee;
ObolLidoSplitFactory internal lidoSplitFactory;
ObolLidoSplitFactory internal lidoSplitFactoryWithFee;

LidoSplit internal lidoSplit;
LidoSplit internal lidoSplitWithFee;
ObolLidoSplit internal lidoSplit;
ObolLidoSplit internal lidoSplitWithFee;

address demoSplit;
address feeRecipient;
Expand All @@ -29,14 +29,14 @@ contract LidoSplitTest is LidoSplitTestHelper, Test {
feeRecipient = makeAddr("feeRecipient");
feeShare = 1e4;

lidoSplitFactory = new LidoSplitFactory(
lidoSplitFactory = new ObolLidoSplitFactory(
address(0),
0,
ERC20(STETH_MAINNET_ADDRESS),
ERC20(WSTETH_MAINNET_ADDRESS)
);

lidoSplitFactoryWithFee = new LidoSplitFactory(
lidoSplitFactoryWithFee = new ObolLidoSplitFactory(
feeRecipient,
feeShare,
ERC20(STETH_MAINNET_ADDRESS),
Expand All @@ -45,14 +45,31 @@ contract LidoSplitTest is LidoSplitTestHelper, Test {

demoSplit = makeAddr("demoSplit");

lidoSplit = LidoSplit(lidoSplitFactory.createSplit(demoSplit));
lidoSplitWithFee = LidoSplit(lidoSplitFactoryWithFee.createSplit(demoSplit));
lidoSplit = ObolLidoSplit(lidoSplitFactory.createSplit(demoSplit));
lidoSplitWithFee = ObolLidoSplit(lidoSplitFactoryWithFee.createSplit(demoSplit));

mERC20 = new MockERC20("Test Token", "TOK", 18);
mERC20.mint(type(uint256).max);
}

function test_CannotCreateInvalidFeeRecipient() public {}
function test_CannotCreateInvalidFeeRecipient() public {
vm.expectRevert(
ObolLidoSplit.Invalid_FeeRecipient.selector
);
new ObolLidoSplit(address(0), 10, ERC20(STETH_MAINNET_ADDRESS), ERC20(WSTETH_MAINNET_ADDRESS));
}

function test_CannotCreateInvalidFeeShare() public {
vm.expectRevert(
abi.encodeWithSelector(ObolLidoSplit.Invalid_FeeShare.selector, PERCENTAGE_SCALE + 1)
);
new ObolLidoSplit(address(1), PERCENTAGE_SCALE + 1, ERC20(STETH_MAINNET_ADDRESS), ERC20(WSTETH_MAINNET_ADDRESS));

vm.expectRevert(
abi.encodeWithSelector(ObolLidoSplit.Invalid_FeeShare.selector, PERCENTAGE_SCALE)
);
new ObolLidoSplit(address(1), PERCENTAGE_SCALE, ERC20(STETH_MAINNET_ADDRESS), ERC20(WSTETH_MAINNET_ADDRESS));
}

function test_CloneArgsIsCorrect() public {
assertEq(lidoSplit.splitWallet(), demoSplit, "invalid address");
Expand Down Expand Up @@ -87,10 +104,10 @@ contract LidoSplitTest is LidoSplitTestHelper, Test {
}

function testCannot_RescueLidoTokens() public {
vm.expectRevert(LidoSplit.Invalid_Address.selector);
vm.expectRevert(ObolLidoSplit.Invalid_Address.selector);
lidoSplit.rescueFunds(address(STETH_MAINNET_ADDRESS));

vm.expectRevert(LidoSplit.Invalid_Address.selector);
vm.expectRevert(ObolLidoSplit.Invalid_Address.selector);
lidoSplit.rescueFunds(address(WSTETH_MAINNET_ADDRESS));
}

Expand Down Expand Up @@ -151,14 +168,14 @@ contract LidoSplitTest is LidoSplitTestHelper, Test {
vm.assume(amountToDistribute > 1 ether);
vm.assume(amountToDistribute < 10 ether);

LidoSplitFactory fuzzFactorySplitWithFee = new LidoSplitFactory(
ObolLidoSplitFactory fuzzFactorySplitWithFee = new ObolLidoSplitFactory(
fuzzFeeRecipient,
fuzzFeeShare,
ERC20(STETH_MAINNET_ADDRESS),
ERC20(WSTETH_MAINNET_ADDRESS)
);

LidoSplit fuzzSplitWithFee = LidoSplit(fuzzFactorySplitWithFee.createSplit(anotherSplit));
ObolLidoSplit fuzzSplitWithFee = ObolLidoSplit(fuzzFactorySplitWithFee.createSplit(anotherSplit));

vm.prank(0x2bf3937b8BcccE4B65650F122Bb3f1976B937B2f);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract LidoSplitTestHelper {
contract ObolLidoSplitTestHelper {
address internal STETH_MAINNET_ADDRESS = address(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84);
address internal WSTETH_MAINNET_ADDRESS = address(0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0);
address internal RANDOM_stETH_ACCOUNT_ADDRESS = address(0x2bf3937b8BcccE4B65650F122Bb3f1976B937B2f);
Expand Down
14 changes: 7 additions & 7 deletions src/test/lido/integration/LidoSplitIntegrationTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
pragma solidity ^0.8.19;

import "forge-std/Test.sol";
import {LidoSplitFactory, LidoSplit} from "src/lido/LidoSplitFactory.sol";
import {ObolLidoSplitFactory, ObolLidoSplit} from "src/lido/ObolLidoSplitFactory.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {LidoSplitTestHelper} from "../LidoSplitTestHelper.sol";
import {ObolLidoSplitTestHelper} from "../ObolLidoSplitTestHelper.sol";
import {ISplitMain} from "src/interfaces/ISplitMain.sol";

contract LidoSplitIntegrationTest is LidoSplitTestHelper, Test {
LidoSplitFactory internal lidoSplitFactory;
LidoSplit internal lidoSplit;
contract ObolLidoSplitIntegrationTest is ObolLidoSplitTestHelper, Test {
ObolLidoSplitFactory internal lidoSplitFactory;
ObolLidoSplit internal lidoSplit;

address splitter;

Expand All @@ -22,7 +22,7 @@ contract LidoSplitIntegrationTest is LidoSplitTestHelper, Test {
uint256 mainnetBlock = 17_421_005;
vm.createSelectFork(getChain("mainnet").rpcUrl, mainnetBlock);

lidoSplitFactory = new LidoSplitFactory(
lidoSplitFactory = new ObolLidoSplitFactory(
address(0),
0,
ERC20(STETH_MAINNET_ADDRESS),
Expand All @@ -39,7 +39,7 @@ contract LidoSplitIntegrationTest is LidoSplitTestHelper, Test {

splitter = ISplitMain(SPLIT_MAIN_MAINNET).createSplit(accounts, percentAllocations, 0, address(0));

lidoSplit = LidoSplit(lidoSplitFactory.createSplit(splitter));
lidoSplit = ObolLidoSplit(lidoSplitFactory.createSplit(splitter));
}

function test_CanDistribute() public {
Expand Down

0 comments on commit fd244a0

Please sign in to comment.