Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added decrease liquidity single V4 #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,14 @@ Re-simulate `DeployUniV3Automan` with a dry-run to verify that the deployment ad
Generate the standard JSON input and verify the contract on Etherscan with it:

```shell
forge verify-contract 0x00000000Ede6d8D217c60f93191C060747324bca UniV3Automan --optimizer-runs 4194304 --constructor-args 0x000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000beef63ae5a2102506e8a352a5bb32aa8b30b3112 --show-standard-json-input > etherscan.json
forge verify-contract 0x0000003858948F29A38C6c3Ca09a1cD53a58DC34 UniV3Automan --optimizer-runs 4194304 --constructor-args 0x000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000beef63ae5a2102506e8a352a5bb32aa8b30b3112 --show-standard-json-input > UniV3Automan.json
forge verify-contract 0x00000004D523574c93021f52E520ec4fb2FFA564 UniV3OptimalSwapRouter --optimizer-runs 4194304 --constructor-args 0x000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88 --show-standard-json-input > UniV3OptimalSwapRouter.json
```

Constructor args can be encoded easily using an online ABI tool like https://abi.hashex.org. The above example shows `UniV3Automan` constructor args consisting of the nonfungible position manager contract address followed by the deployer address as the temporary Automan owner during deployment.

When verifying contracts on etherscan, omit '0x' from Constructor Arguments ABI-encoded.

**Deployed Contracts**

* [Mainnet](https://etherscan.io/address/0x00000000ede6d8d217c60f93191c060747324bca)
Expand Down
326 changes: 326 additions & 0 deletions broadcast/DeployUniV3Automan.s.sol/42161/run-1736978362.json

Large diffs are not rendered by default.

241 changes: 141 additions & 100 deletions broadcast/DeployUniV3Automan.s.sol/42161/run-latest.json

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions script/DeployUniV3Automan.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ import {UniV3Automan} from "../src/UniV3Automan.sol";
contract DeployUniV3Automan is Script {
struct DeployParams {
// Has to be alphabetically ordered per https://book.getfoundry.sh/cheatcodes/parse-json
bytes32 automanSalt;
address controller;
UniV3Automan.FeeConfig feeConfig;
INPM npm;
address optimalSwapRouter; // Deploy optimal swap router if parsed as address(0).
bytes32 optimalSwapRouterSalt;
address owner;
}

// https://github.com/pcaversaccio/create2deployer
Create2Deployer internal constant create2deployer = Create2Deployer(0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2);
// bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b3112e429609defd54e2600050000; // mainnet, arbitrum_one, optimism, and polygon
// bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b31126da13df7e082a0874b020028; // base
// bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b3112350766a71aff01bd0a000040; // bnb
// bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b31129e5100c6f38046891d010080; // avalanche
// bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b31127d2397bf1d3d45097b00002c; // scroll
bytes32 internal constant automanSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b311279cd7418ade4641cb50000e0; // manta
bytes32 internal constant optimalSwapSalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b31127dfc30de0987800003da9a65;
bytes32 internal constant routerProxySalt = 0xbeef63ae5a2102506e8a352a5bb32aa8b30b3112bc2281f12f80c0000280f6fd;

// https://book.getfoundry.sh/tutorials/best-practices#scripts
function readInput(string memory input) internal view returns (string memory) {
Expand Down Expand Up @@ -60,11 +54,11 @@ contract DeployUniV3Automan is Script {
console2.log("OptimalSwapRouter initCodeHash:");
console2.logBytes32(initCodeHash);
UniV3OptimalSwapRouter optimalSwapRouter = UniV3OptimalSwapRouter(
payable(create2deployer.computeAddress(optimalSwapSalt, initCodeHash))
payable(create2deployer.computeAddress(params.optimalSwapRouterSalt, initCodeHash))
);
if (address(optimalSwapRouter).code.length == 0) {
// Deploy optimalSwapRouter
create2deployer.deploy(0, optimalSwapSalt, initCode);
create2deployer.deploy(0, params.optimalSwapRouterSalt, initCode);
console2.log("UniV3OptimalSwapRouter deployed at: %s", address(optimalSwapRouter));
}
params.optimalSwapRouter = address(optimalSwapRouter);
Expand All @@ -78,11 +72,11 @@ contract DeployUniV3Automan is Script {
console2.log("UniV3Automan initCodeHash:");
console2.logBytes32(initCodeHash);
// Compute the address of the contract to be deployed
UniV3Automan automan = UniV3Automan(payable(create2deployer.computeAddress(automanSalt, initCodeHash)));
UniV3Automan automan = UniV3Automan(payable(create2deployer.computeAddress(params.automanSalt, initCodeHash)));

if (address(automan).code.length == 0) {
// Deploy automan
create2deployer.deploy(0, automanSalt, initCode);
create2deployer.deploy(0, params.automanSalt, initCode);

// Set up automan
automan.setFeeConfig(params.feeConfig);
Expand Down
4 changes: 3 additions & 1 deletion script/UniV3Automan_input/42161/automan_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"feeCollector": "0x145304a5cfEc1B616Cf035C43f084CE1233d9Ea7"
},
"controller": "0x1Dd333d27746D2283D01C5a759cB04A0eAD821D4",
"optimalSwapRouter": "0x00000000063E0E1E06A0FE61e16bE8Bdec1BEA31"
"automanSalt": "0xbeef63ae5a2102506e8a352a5bb32aa8b30b311269530b801afaa8bd16010080",
"optimalSwapRouter": "0x0000000000000000000000000000000000000000",
"optimalSwapRouterSalt": "0xbeef63ae5a2102506e8a352a5bb32aa8b30b311225946149e8de306029000020"
}
Loading
Loading