Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51)
## Changes ### Configuration - Added .solhint.json with recommended rules + custom config - 160 char line length (warn) - Double quotes enforcement (error) - Explicit visibility required (error) - Console statements allowed (scripts/tests need them) - Gas optimization warnings enabled - Ignores test/helpers/, lib/, out/, cache/, broadcast/ - Added foundry.toml [fmt] section - 160 char line length - 4-space tabs - Double quotes - Thousands separators for numbers - Sort imports enabled - Added .lintstagedrc.json for pre-commit auto-fix - Runs solhint --fix on .sol files - Runs forge fmt on .sol files - Added husky pre-commit hook via lint-staged ### NPM Scripts - lint:sol - run solhint - lint:sol:fix - auto-fix solhint issues - format:sol - format with forge fmt - format:sol:check - check formatting - lint / lint:fix - combined commands ### Code Changes - Added explicit visibility modifiers (internal) to constants in scripts and tests - Fixed quote style in DeployLocal.sol - All Solidity files formatted with forge fmt ## Verification - ✅ forge fmt --check passes - ✅ No solhint errors (warnings only) - ✅ forge build succeeds - ✅ forge test passes (107/107) resolves #44 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/51
This commit is contained in:
parent
f8927b426e
commit
d7c2184ccf
45 changed files with 2853 additions and 1225 deletions
|
|
@ -1,15 +1,16 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "forge-std/Script.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
|
||||
import { LiquidityManager } from "../src/LiquidityManager.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import { ERC1967Proxy } from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
||||
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "forge-std/Script.sol";
|
||||
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
|
||||
|
|
@ -74,11 +75,7 @@ contract DeployBase is Script {
|
|||
address optimizerAddress;
|
||||
if (optimizer == address(0)) {
|
||||
Optimizer optimizerImpl = new Optimizer();
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
"initialize(address,address)",
|
||||
address(kraiken),
|
||||
address(stake)
|
||||
);
|
||||
bytes memory params = abi.encodeWithSignature("initialize(address,address)", address(kraiken), address(stake));
|
||||
ERC1967Proxy proxy = new ERC1967Proxy(address(optimizerImpl), params);
|
||||
optimizerAddress = address(proxy);
|
||||
console.log("Optimizer deployed at:", optimizerAddress);
|
||||
|
|
@ -88,12 +85,7 @@ contract DeployBase is Script {
|
|||
}
|
||||
|
||||
// Deploy LiquidityManager
|
||||
liquidityManager = new LiquidityManager(
|
||||
v3Factory,
|
||||
weth,
|
||||
address(kraiken),
|
||||
optimizerAddress
|
||||
);
|
||||
liquidityManager = new LiquidityManager(v3Factory, weth, address(kraiken), optimizerAddress);
|
||||
console.log("LiquidityManager deployed at:", address(liquidityManager));
|
||||
|
||||
// Set fee destination
|
||||
|
|
@ -115,4 +107,4 @@ contract DeployBase is Script {
|
|||
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {DeployBase} from "./DeployBase.sol";
|
||||
import { DeployBase } from "./DeployBase.sol";
|
||||
|
||||
/**
|
||||
* @title DeployBaseMainnet
|
||||
|
|
@ -21,4 +21,4 @@ contract DeployBaseMainnet is DeployBase {
|
|||
// Leave as address(0) to deploy new optimizer
|
||||
optimizer = address(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import {DeployBase} from "./DeployBase.sol";
|
||||
import { DeployBase } from "./DeployBase.sol";
|
||||
|
||||
/**
|
||||
* @title DeployBaseSepolia
|
||||
|
|
@ -19,4 +19,4 @@ contract DeployBaseSepolia is DeployBase {
|
|||
// optimizer = 0xFCFa3b066981027516121bd27a9B1cBb9C00c5Fd;
|
||||
optimizer = address(0); // Deploy new optimizer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "forge-std/Script.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
|
||||
import { LiquidityManager } from "../src/LiquidityManager.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import { ERC1967Proxy } from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
||||
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "forge-std/Script.sol";
|
||||
|
||||
/**
|
||||
* @title DeployLocal
|
||||
|
|
@ -19,12 +20,12 @@ import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
|||
contract DeployLocal is Script {
|
||||
using UniswapHelpers for IUniswapV3Pool;
|
||||
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
uint24 internal constant FEE = uint24(10_000);
|
||||
|
||||
// Configuration
|
||||
address constant feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011;
|
||||
address constant weth = 0x4200000000000000000000000000000000000006;
|
||||
address constant v3Factory = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
|
||||
address internal constant feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011;
|
||||
address internal constant weth = 0x4200000000000000000000000000000000000006;
|
||||
address internal constant v3Factory = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
|
||||
|
||||
// Deployed contracts
|
||||
Kraiken public kraiken;
|
||||
|
|
@ -87,22 +88,13 @@ contract DeployLocal is Script {
|
|||
|
||||
// Deploy Optimizer
|
||||
Optimizer optimizerImpl = new Optimizer();
|
||||
bytes memory params = abi.encodeWithSignature(
|
||||
"initialize(address,address)",
|
||||
address(kraiken),
|
||||
address(stake)
|
||||
);
|
||||
bytes memory params = abi.encodeWithSignature("initialize(address,address)", address(kraiken), address(stake));
|
||||
ERC1967Proxy proxy = new ERC1967Proxy(address(optimizerImpl), params);
|
||||
address optimizerAddress = address(proxy);
|
||||
console.log("\n[4/6] Optimizer deployed:", optimizerAddress);
|
||||
|
||||
// Deploy LiquidityManager
|
||||
liquidityManager = new LiquidityManager(
|
||||
v3Factory,
|
||||
weth,
|
||||
address(kraiken),
|
||||
optimizerAddress
|
||||
);
|
||||
liquidityManager = new LiquidityManager(v3Factory, weth, address(kraiken), optimizerAddress);
|
||||
console.log("\n[5/6] LiquidityManager deployed:", address(liquidityManager));
|
||||
|
||||
// Configure contracts
|
||||
|
|
@ -126,8 +118,8 @@ contract DeployLocal is Script {
|
|||
console.log("1. Fund LiquidityManager with ETH:");
|
||||
console.log(" cast send", address(liquidityManager), "--value 0.1ether");
|
||||
console.log("2. Call recenter to initialize positions:");
|
||||
console.log(" cast send", address(liquidityManager), '"recenter()"');
|
||||
console.log(" cast send", address(liquidityManager), "\"recenter()\"");
|
||||
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
pragma solidity ^0.8.19;
|
||||
|
||||
import "forge-std/Script.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
|
||||
import { LiquidityManager } from "../src/LiquidityManager.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import { ERC1967Proxy } from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
||||
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
||||
import "../src/Kraiken.sol";
|
||||
import "../src/Stake.sol";
|
||||
import "../src/Optimizer.sol";
|
||||
import "../src/helpers/UniswapHelpers.sol";
|
||||
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
||||
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
||||
import "forge-std/Script.sol";
|
||||
|
||||
uint24 constant FEE = uint24(10_000);
|
||||
|
||||
contract DeployScript is Script {
|
||||
using UniswapHelpers for IUniswapV3Pool;
|
||||
|
||||
bool token0isWeth;
|
||||
address feeDest;
|
||||
address weth;
|
||||
address v3Factory;
|
||||
address twabc;
|
||||
bool internal token0isWeth;
|
||||
address internal feeDest;
|
||||
address internal weth;
|
||||
address internal v3Factory;
|
||||
address internal twabc;
|
||||
|
||||
function run() public {
|
||||
string memory seedPhrase = vm.readFile(".secret");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue