-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity 0.8.17; | ||
|
||
import {IMarginalV1LBPoolDeployer} from "./interfaces/IMarginalV1LBPoolDeployer.sol"; | ||
import {MarginalV1LBPool} from "./MarginalV1LBPool.sol"; | ||
|
||
contract MarginalV1LBPoolDeployer is IMarginalV1LBPoolDeployer { | ||
/// @inheritdoc IMarginalV1LBPoolDeployer | ||
function deploy( | ||
address token0, | ||
address token1, | ||
int24 tickLower, | ||
int24 tickUpper, | ||
address supplier, | ||
uint256 blockTimestampInitialize | ||
) external returns (address pool) { | ||
pool = address( | ||
new MarginalV1LBPool{ | ||
salt: keccak256( | ||
abi.encode( | ||
msg.sender, | ||
token0, | ||
token1, | ||
tickLower, | ||
tickUpper, | ||
supplier, | ||
blockTimestampInitialize | ||
) | ||
) | ||
}( | ||
msg.sender, | ||
token0, | ||
token1, | ||
tickLower, | ||
tickUpper, | ||
supplier, | ||
blockTimestampInitialize | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
contracts/receiver/MarginalV1LBLiquidityReceiverDeployer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity =0.8.15; | ||
|
||
import {MarginalV1LBLiquidityReceiver} from "./MarginalV1LBLiquidityReceiver.sol"; | ||
|
||
import {IMarginalV1LBPool} from "../interfaces/IMarginalV1LBPool.sol"; | ||
import {IMarginalV1LBReceiverDeployer} from "../interfaces/receiver/IMarginalV1LBReceiverDeployer.sol"; | ||
import {IMarginalV1LBLiquidityReceiverDeployer} from "../interfaces/receiver/liquidity/IMarginalV1LBLiquidityReceiverDeployer.sol"; | ||
|
||
contract MarginalV1LBLiquidityReceiverDeployer is | ||
IMarginalV1LBLiquidityReceiverDeployer | ||
{ | ||
/// @inheritdoc IMarginalV1LBLiquidityReceiverDeployer | ||
address public immutable uniswapV3NonfungiblePositionManager; | ||
/// @inheritdoc IMarginalV1LBLiquidityReceiverDeployer | ||
address public immutable marginalV1Factory; | ||
/// @inheritdoc IMarginalV1LBLiquidityReceiverDeployer | ||
address public immutable marginalV1PoolInitializer; | ||
/// @inheritdoc IMarginalV1LBLiquidityReceiverDeployer | ||
address public immutable marginalV1Router; | ||
/// @inheritdoc IMarginalV1LBLiquidityReceiverDeployer | ||
address public immutable WETH9; | ||
|
||
modifier onlyPoolSupplier(address pool) { | ||
if (msg.sender != IMarginalV1LBPool(pool).supplier()) | ||
revert Unauthorized(); | ||
_; | ||
} | ||
|
||
error Unauthorized(); | ||
|
||
constructor( | ||
address _uniswapV3NonfungiblePositionManager, | ||
address _marginalV1Factory, | ||
address _marginalV1PoolInitializer, | ||
address _marginalV1Router, | ||
address _WETH9 | ||
) { | ||
uniswapV3NonfungiblePositionManager = _uniswapV3NonfungiblePositionManager; | ||
marginalV1Factory = _marginalV1Factory; | ||
marginalV1PoolInitializer = _marginalV1PoolInitializer; | ||
marginalV1Router = _marginalV1Router; | ||
WETH9 = _WETH9; | ||
} | ||
|
||
/// @inheritdoc IMarginalV1LBReceiverDeployer | ||
function deploy( | ||
address pool, | ||
bytes calldata data | ||
) | ||
external | ||
virtual | ||
override(IMarginalV1LBReceiverDeployer) | ||
onlyPoolSupplier(pool) | ||
returns (address receiver) | ||
{ | ||
address factory = IMarginalV1LBPool(pool).factory(); | ||
receiver = address( | ||
new MarginalV1LBLiquidityReceiver{ | ||
salt: keccak256(abi.encode(msg.sender, pool)) | ||
}(factory, marginalV1Factory, WETH9, pool, data) | ||
); | ||
} | ||
} |