-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* UniV3 routing logic * Fix comments * Unused contracts * Add scripts and script test * remove comments * Add blast manager and script * fix natspec * remove unused * Add uni to abi exports * fix blast deployment * fix deployment script * audit return 1 * fix comments
- Loading branch information
Showing
66 changed files
with
3,764 additions
and
40 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
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,50 @@ | ||
const fs = require("fs"); | ||
|
||
/** | ||
* Outputs the compiler output to a file. | ||
* @typedef {Object} CompilerOutput | ||
* @property {string} bytecode The bytecode of the contract. | ||
*/ | ||
|
||
const files = [ | ||
"node_modules/@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json", | ||
"node_modules/@uniswap/v3-periphery/artifacts/contracts/NonfungibleTokenPositionDescriptor.sol/NonfungibleTokenPositionDescriptor.json", | ||
"node_modules/@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json", | ||
]; | ||
const outputs = [ | ||
__dirname + "/uni-out/UniswapV3Factory.txt", | ||
__dirname + "/uni-out/NonfungibleTokenPositionDescriptor.txt", | ||
__dirname + "/uni-out/NonfungiblePositionManager.txt", | ||
]; | ||
|
||
async function main() { | ||
await Promise.all( | ||
files.map(async (file, idx) => { | ||
const fileContent = await new Promise((resolve, reject) => { | ||
fs.readFile(file, "utf8", (err, data) => { | ||
if (err) reject(err); | ||
resolve(data); | ||
}); | ||
}); | ||
/** | ||
* @type {CompilerOutput} | ||
*/ | ||
const data = JSON.parse(fileContent); | ||
const bytecode = data.bytecode.replace( | ||
/__\$[a-fA-F0-9]+\$__/gm, | ||
"0".repeat(40), | ||
); | ||
|
||
await new Promise((resolve, reject) => { | ||
fs.writeFile(outputs[idx], bytecode, (err) => { | ||
if (err) reject(err); | ||
resolve(); | ||
}); | ||
}); | ||
}), | ||
); | ||
} | ||
|
||
main() | ||
.then(() => console.log("done")) | ||
.catch(console.error); |
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
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
74 changes: 74 additions & 0 deletions
74
script/strategies/routing_logic/deployers/uni-v3/BlastUniV3RoutingLogicDeployer.s.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,74 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "@mgv/forge-std/Script.sol"; | ||
import {BlastUniswapV3Manager} from "@mgv-strats/src/strategies/chains/blast/routing_logic/BlastUniswapV3Manager.sol"; | ||
import {INonfungiblePositionManager} from | ||
"@mgv-strats/src/strategies/vendor/uniswap/v3/periphery/interfaces/INonfungiblePositionManager.sol"; | ||
import {RouterProxyFactory} from "@mgv-strats/src/strategies/routers/RouterProxyFactory.sol"; | ||
import {AbstractRouter} from "@mgv-strats/src/strategies/routers/abstract/AbstractRouter.sol"; | ||
import {UniswapV3RoutingLogic} from | ||
"@mgv-strats/src/strategies/routing_logic/restaking/uni-v3/UniswapV3RoutingLogic.sol"; | ||
import {Deployer} from "@mgv/script/lib/Deployer.sol"; | ||
import {IERC20Rebasing} from "@mgv-strats/src/strategies/vendor/blast/IERC20Rebasing.sol"; | ||
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol"; | ||
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol"; | ||
|
||
/* Deploys a UniswapV3Logic instance */ | ||
contract BlastUniV3RoutingLogicDeployer is Deployer { | ||
function run() public { | ||
address[] memory tokens = vm.envAddress("REBASING_TOKENS", ","); | ||
IERC20Rebasing[] memory rebasingTokens = new IERC20Rebasing[](tokens.length); | ||
for (uint i = 0; i < tokens.length; i++) { | ||
rebasingTokens[i] = IERC20Rebasing(tokens[i]); | ||
} | ||
innerRun({ | ||
positionManager: INonfungiblePositionManager(vm.envAddress("UNISWAP_V3_POSITION_MANAGER")), | ||
factory: RouterProxyFactory(envAddressOrName("ROUTER_PROXY_FACTORY", "RouterProxyFactory")), | ||
implementation: AbstractRouter(envAddressOrName("SMART_ROUTER_IMPLEMENTATION", "MangroveOrder-Router")), | ||
forkName: vm.envString("FORK_NAME"), | ||
tokens: rebasingTokens, | ||
admin: vm.envAddress("ADMIN"), | ||
blastContract: IBlast(vm.envAddress("BLAST")), | ||
pointsContract: IBlastPoints(vm.envAddress("BLAST_POINTS")), | ||
pointsOperator: vm.envAddress("BLAST_POINTS_OPERATOR"), | ||
blastGovernor: vm.envAddress("BLAST_GOVERNOR") | ||
}); | ||
outputDeployment(); | ||
} | ||
|
||
function innerRun( | ||
INonfungiblePositionManager positionManager, | ||
RouterProxyFactory factory, | ||
AbstractRouter implementation, | ||
string memory forkName, | ||
IERC20Rebasing[] memory tokens, | ||
address admin, | ||
IBlast blastContract, | ||
IBlastPoints pointsContract, | ||
address pointsOperator, | ||
address blastGovernor | ||
) public { | ||
broadcast(); | ||
BlastUniswapV3Manager uniswapV3Manager = new BlastUniswapV3Manager( | ||
tokens, | ||
admin, | ||
positionManager, | ||
factory, | ||
implementation, | ||
pointsContract, | ||
pointsOperator, | ||
blastContract, | ||
blastGovernor | ||
); | ||
string memory managerName = string.concat("UniswapV3Manager-", forkName); | ||
fork.set(managerName, address(uniswapV3Manager)); | ||
console.log("UniswapV3Manager deployed", address(uniswapV3Manager)); | ||
|
||
broadcast(); | ||
UniswapV3RoutingLogic uniswapV3RoutingLogic = new UniswapV3RoutingLogic(uniswapV3Manager); | ||
string memory logicName = string.concat("UniswapV3RoutingLogic-", forkName); | ||
fork.set(logicName, address(uniswapV3RoutingLogic)); | ||
console.log("UniswapV3RoutingLogic deployed", address(uniswapV3RoutingLogic)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
script/strategies/routing_logic/deployers/uni-v3/UniV3RoutingLogicDeployer.s.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,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console} from "@mgv/forge-std/Script.sol"; | ||
import {UniswapV3Manager} from "@mgv-strats/src/strategies/routing_logic/restaking/uni-v3/UniswapV3Manager.sol"; | ||
import {INonfungiblePositionManager} from | ||
"@mgv-strats/src/strategies/vendor/uniswap/v3/periphery/interfaces/INonfungiblePositionManager.sol"; | ||
import {RouterProxyFactory} from "@mgv-strats/src/strategies/routers/RouterProxyFactory.sol"; | ||
import {AbstractRouter} from "@mgv-strats/src/strategies/routers/abstract/AbstractRouter.sol"; | ||
import {UniswapV3RoutingLogic} from | ||
"@mgv-strats/src/strategies/routing_logic/restaking/uni-v3/UniswapV3RoutingLogic.sol"; | ||
import {Deployer} from "@mgv/script/lib/Deployer.sol"; | ||
|
||
/* Deploys a UniswapV3Logic instance */ | ||
contract UniV3RoutingLogicDeployer is Deployer { | ||
function run() public { | ||
innerRun({ | ||
positionManager: INonfungiblePositionManager(vm.envAddress("UNISWAP_V3_POSITION_MANAGER")), | ||
factory: RouterProxyFactory(envAddressOrName("ROUTER_PROXY_FACTORY", "RouterProxyFactory")), | ||
implementation: AbstractRouter(envAddressOrName("SMART_ROUTER_IMPLEMENTATION", "MangroveOrder-Router")), | ||
forkName: vm.envString("FORK_NAME") | ||
}); | ||
outputDeployment(); | ||
} | ||
|
||
function innerRun( | ||
INonfungiblePositionManager positionManager, | ||
RouterProxyFactory factory, | ||
AbstractRouter implementation, | ||
string memory forkName | ||
) public { | ||
broadcast(); | ||
UniswapV3Manager uniswapV3Manager = new UniswapV3Manager(positionManager, factory, implementation); | ||
string memory managerName = string.concat("UniswapV3Manager-", forkName); | ||
fork.set(managerName, address(uniswapV3Manager)); | ||
console.log("UniswapV3Manager deployed", address(uniswapV3Manager)); | ||
|
||
broadcast(); | ||
UniswapV3RoutingLogic uniswapV3RoutingLogic = new UniswapV3RoutingLogic(uniswapV3Manager); | ||
string memory logicName = string.concat("UniswapV3RoutingLogic-", forkName); | ||
fork.set(logicName, address(uniswapV3RoutingLogic)); | ||
console.log("UniswapV3RoutingLogic deployed", address(uniswapV3RoutingLogic)); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/strategies/chains/blast/routing_logic/BlastUniswapV3Manager.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,63 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import { | ||
UniswapV3Manager, | ||
INonfungiblePositionManager, | ||
RouterProxyFactory, | ||
AbstractRouter | ||
} from "@mgv-strats/src/strategies/routing_logic/restaking/uni-v3/UniswapV3Manager.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {IERC20Rebasing, YieldMode} from "@mgv-strats/src/strategies/vendor/blast/IERC20Rebasing.sol"; | ||
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol"; | ||
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol"; | ||
|
||
/// @title BlastUniswapV3Manager | ||
/// @author Mangrove | ||
/// @notice A UniswapV3Manager that can handle rebasing tokens from Blast | ||
contract BlastUniswapV3Manager is UniswapV3Manager, Ownable { | ||
/// @notice Constructor | ||
/// @param _initTokens The tokens to initialize | ||
/// @param admin the admin address | ||
/// @param positionManager the position manager | ||
/// @param factory the router proxy factory | ||
/// @param implementation the router implementation | ||
constructor( | ||
IERC20Rebasing[] memory _initTokens, | ||
address admin, | ||
INonfungiblePositionManager positionManager, | ||
RouterProxyFactory factory, | ||
AbstractRouter implementation, | ||
IBlastPoints pointsContract, | ||
address pointsOperator, | ||
IBlast blastContract, | ||
address blastGovernor | ||
) UniswapV3Manager(positionManager, factory, implementation) Ownable(admin) { | ||
for (uint i = 0; i < _initTokens.length; i++) { | ||
_initRebasingToken(_initTokens[i]); | ||
} | ||
pointsContract.configurePointsOperator(pointsOperator); | ||
blastContract.configureClaimableGas(); | ||
blastContract.configureGovernor(blastGovernor); | ||
} | ||
|
||
/// @notice Initializes a rebasing token with the correct yield mode | ||
/// @param token The token to configure | ||
function _initRebasingToken(IERC20Rebasing token) internal { | ||
token.configure(YieldMode.CLAIMABLE); | ||
} | ||
|
||
/// @notice Initializes a rebasing token with the correct yield mode | ||
/// @param token The token to configure | ||
function initRebasingToken(IERC20Rebasing token) external onlyOwner { | ||
_initRebasingToken(token); | ||
} | ||
|
||
/// @notice Claims yield from a rebasing token | ||
/// @param token The token to claim from | ||
/// @param recipient The recipient of the claim | ||
/// @param amount The amount to claim | ||
function claim(IERC20Rebasing token, address recipient, uint amount) external onlyOwner { | ||
token.claim(recipient, amount); | ||
} | ||
} |
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
Oops, something went wrong.