-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ronin-chain/feature/upgradeable-beacon-proxy
feat: upgradeable beacon proxy
- Loading branch information
Showing
9 changed files
with
115 additions
and
84 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 |
---|---|---|
|
@@ -15,4 +15,6 @@ docs/ | |
node_modules/ | ||
yarn-error.log | ||
.yarn | ||
.yarnrc.yml | ||
.yarnrc.yml | ||
|
||
.vscode/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity =0.7.6; | ||
|
||
import "@openzeppelin/contracts/proxy/BeaconProxy.sol"; | ||
|
||
import "./interfaces/IKatanaV3PoolDeployer.sol"; | ||
import "./interfaces/IKatanaV3Factory.sol"; | ||
|
||
import "./KatanaV3Pool.sol"; | ||
|
||
contract KatanaV3PoolProxy is BeaconProxy { | ||
constructor() BeaconProxy(address(0), "") { } | ||
|
||
/// @dev This function will be called with zero arguments but modified to include the pool's immutable parameters. | ||
function _setBeacon(address beacon, bytes memory data) internal virtual override { | ||
(address factory, address token0, address token1, uint24 fee, int24 tickSpacing) = | ||
IKatanaV3PoolDeployer(msg.sender).parameters(); | ||
|
||
beacon = IKatanaV3Factory(factory).beacon(); | ||
data = abi.encodeWithSelector(KatanaV3Pool.initializeImmutables.selector, factory, token0, token1, fee, tickSpacing); | ||
|
||
super._setBeacon(beacon, data); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity =0.7.6; | ||
pragma abicoder v2; | ||
|
||
import { Test, console } from "forge-std/Test.sol"; | ||
|
||
import { KatanaV3Factory } from "@katana/v3-contracts/core/KatanaV3Factory.sol"; | ||
import { IKatanaV3Pool } from "@katana/v3-contracts/core/interfaces/IKatanaV3Pool.sol"; | ||
|
||
contract KatanaV3FactoryTest is Test { | ||
KatanaV3Factory factory; | ||
|
||
function setUp() public { | ||
factory = new KatanaV3Factory(); | ||
} | ||
|
||
function test_createPool() public { | ||
address token0 = makeAddr("token0"); | ||
address token1 = makeAddr("token1"); | ||
uint24 fee = 3000; // 0.3% | ||
int24 tickSpacing = 60; | ||
|
||
address pool = factory.createPool(token0, token1, fee); | ||
|
||
assertEq(IKatanaV3Pool(pool).factory(), address(factory)); | ||
assertEq(IKatanaV3Pool(pool).token0(), token0); | ||
assertEq(IKatanaV3Pool(pool).token1(), token1); | ||
assertEq(uint256(IKatanaV3Pool(pool).fee()), uint256(fee)); | ||
assertEq(uint256(IKatanaV3Pool(pool).tickSpacing()), uint256(tickSpacing)); | ||
} | ||
} |