Skip to content

Commit

Permalink
fix: factory address
Browse files Browse the repository at this point in the history
  • Loading branch information
robertleifke committed Mar 17, 2024
1 parent 8cf69e8 commit b5efa47
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export PRIVATE_KEY="YOUR_PRIVATE_KEY"

export ALCHEMY_RPC_URL="YOUR_RPC_URL"
export SEPOLIA_RPC_URL="YOUR_RPC_URL"

export ETHERSCAN_KEY="YOUR_ETHERSCAN_KEY"
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
forge-std/=lib/forge-std/src/
create3-factory/=lib/create3-factory/src/
24 changes: 15 additions & 9 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,26 @@ contract Deploy is Script {
address constant weth = 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14;

function run() external returns (address factory, address liquidityManager, address lendgineRouter) {
CREATE3Factory create3 = CREATE3Factory(create3Factory);
// CREATE3Factory create3 = CREATE3Factory(create3Factory);

uint256 pk = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(pk);

factory = create3.deploy(keccak256("NumoFactory"), type(Factory).creationCode);
factory = address(new Factory());

liquidityManager = create3.deploy(
keccak256("NumoLiquidityManager"), bytes.concat(type(LiquidityManager).creationCode, abi.encode(factory, weth))
);
liquidityManager = address(new LiquidityManager(factory, weth));

lendgineRouter = create3.deploy(
keccak256("NumoLendgineRouter"),
bytes.concat(type(LendgineRouter).creationCode, abi.encode(factory, uniV2Factory, uniV3Factory, weth))
);
lendgineRouter = address(new LendgineRouter(factory, uniV2Factory, uniV3Factory, weth));

// factory = create3.deploy(keccak256("NumoFactory"), type(Factory).creationCode);

// liquidityManager = create3.deploy(
// keccak256("NumoLiquidityManager"), bytes.concat(type(LiquidityManager).creationCode, abi.encode(factory, weth))
// );

// lendgineRouter = create3.deploy(
// keccak256("NumoLendgineRouter"),
// bytes.concat(type(LendgineRouter).creationCode, abi.encode(factory, uniV2Factory, uniV3Factory, weth))
// );
}
}
Empty file modified script/sh/deploy.sh
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions src/periphery/libraries/LendgineAddress.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.5.0;

import { Lendgine } from "../../core/Lendgine.sol";

/// @notice Library for computing the address of a lendgine using only its inputs
library LendgineAddress {
uint256 internal constant INIT_CODE_HASH =
54_077_118_415_036_375_799_727_632_405_414_219_288_686_146_435_384_080_671_378_369_222_491_001_741_386;

function computeAddress(
address factory,
Expand All @@ -26,7 +26,7 @@ library LendgineAddress {
hex"ff",
factory,
keccak256(abi.encode(token0, token1, token0Exp, token1Exp, upperBound)),
bytes32(INIT_CODE_HASH)
keccak256(type(Lendgine).creationCode)
)
)
)
Expand Down
6 changes: 4 additions & 2 deletions test/utils/TestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ abstract contract TestHelper is Test, CallbackHelper {
}

function _setUp() internal {
token0 = new MockERC20();
token1 = new MockERC20();
MockERC20 tokenA = new MockERC20();
MockERC20 tokenB = new MockERC20();

(token0, token1) = address(tokenA) < address(tokenB) ? (tokenA, tokenB) : (tokenB, tokenA);

factory = new Factory();
lendgine = Lendgine(factory.createLendgine(address(token0), address(token1), token0Scale, token1Scale, upperBound));
Expand Down

0 comments on commit b5efa47

Please sign in to comment.