Skip to content

Commit

Permalink
Merge pull request #261 from mangrovedao/feat/blast
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis-Amas authored Feb 28, 2024
2 parents 1aa2914 + 1c10860 commit 4f3b6c9
Show file tree
Hide file tree
Showing 18 changed files with 373 additions and 77 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Next version

- Upgrade to @mangrovedao/mangrove-core v2.1.0
- Upgrade to @mangrovedao/mangrove-deployments v2.1.3
- Upgrade to @mangrovedao/context-addresses v1.3.0
- Update Blast integrations

# 2.1.0-2

- Add orbit logic to the exports
Expand Down
4 changes: 3 additions & 1 deletion copyContextAddresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ function getOrCreateNetworkAddresses(networkName) {
return networkAddresses;
}

// Accounts, AAVE v3
// Accounts, AAVE v3, Blast
const allAccounts = contextAddresses.getAllAccounts();
const allAaveV3Addresses = contextAddresses.getAllAaveV3Addresses();
const allBlastAddresses = contextAddresses.getAllBlastAddresses();
for (const [networkName, namedAddresses] of Object.entries(
contextAddresses.toNamedAddressesPerNamedNetwork(
allAccounts,
allAaveV3Addresses,
allBlastAddresses,
),
)) {
const networkAddresses = getOrCreateNetworkAddresses(networkName);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"/README.md"
],
"dependencies": {
"@mangrovedao/mangrove-core": "^2.1.0-0"
"@mangrovedao/mangrove-core": "^2.1.0"
},
"devDependencies": {
"@mangrovedao/context-addresses": "^1.2.0",
"@mangrovedao/mangrove-deployments": "^2.1.1",
"@mangrovedao/context-addresses": "^1.3.0",
"@mangrovedao/mangrove-deployments": "^2.1.3",
"@types/node": "^20.11.5",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,62 @@ import {
} from "@mgv-strats/src/strategies/MangroveAmplifier.sol";
import {BlastMangroveAmplifier} from "@mgv-strats/src/strategies/chains/blast/BlastMangroveAmplifier.sol";
import {BlastSmartRouter} from "@mgv-strats/src/strategies/chains/blast/routers/BlastSmartRouter.sol";
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";

import {StdCheats} from "@mgv/forge-std/StdCheats.sol";

// NB: Must be executed with the --skip-simulation --slow flags:
// - Skip simulation because the Blast predeploys are not known by forge
// - Slow because Blast Sepolia (and maybe Blast) fails to execute transactions
// that interact with a contract that was deployed in the same block.
contract BlastMangroveAmplifierDeployer is MangroveAmplifierDeployer, StdCheats {
IBlast public blastContract;
IBlastPoints public blastPointsContract;

address public blastGovernor;
address public blastPointsOperator;

function run() public override {
blastContract = IBlast(envAddressOrName("BLAST_CONTRACT", "Blast"));
blastPointsContract = IBlastPoints(envAddressOrName("BLAST_POINTS_CONTRACT", "BlastPoints"));
blastGovernor = envAddressOrName("BLAST_GOVERNOR", "BlastGovernor");
blastPointsOperator = envAddressOrName("BLAST_POINTS_OPERATOR", "BlastPointsOperator");

innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
routerProxyFactory: RouterProxyFactory(envAddressOrName("ROUTER_PROXY_FACTORY", "RouterProxyFactory")),
routerImplementation: SmartRouter(envAddressOrName("MANGROVEORDER_ROUTER", "SmartRouter")),
_blastContract: IBlast(envAddressOrName("BLAST_CONTRACT", "Blast")),
_blastPointsContract: IBlastPoints(envAddressOrName("BLAST_POINTS_CONTRACT", "BlastPoints")),
_blastGovernor: envAddressOrName("BLAST_GOVERNOR", "BlastGovernor"),
_blastPointsOperator: envAddressOrName("BLAST_POINTS_OPERATOR", "BlastPointsOperator")
});
outputDeployment();
}

function innerRun(
IMangrove mgv,
RouterProxyFactory routerProxyFactory,
SmartRouter routerImplementation,
IBlast _blastContract,
address _blastGovernor,
IBlastPoints _blastPointsContract,
address _blastPointsOperator
) public {
blastContract = _blastContract;
blastPointsContract = _blastPointsContract;
blastGovernor = _blastGovernor;
blastPointsOperator = _blastPointsOperator;

// forge doesn't know the Blast predeploys, so we need to deploy them.
// Otherwise, the script fails (even with the --skip-simulation flag).
deployCodeTo("Blast.sol", address(blastContract));
deployCodeTo("BlastPoints.sol", address(blastPointsContract));

super.innerRun({mgv: mgv, routerProxyFactory: routerProxyFactory, routerImplementation: routerImplementation});
}

contract BlastMangroveAmplifierDeployer is MangroveAmplifierDeployer {
function deployMangroveAmplifier(
IMangrove mgv,
RouterProxyFactory routerProxyFactory,
Expand All @@ -20,9 +74,25 @@ contract BlastMangroveAmplifierDeployer is MangroveAmplifierDeployer {
BlastSmartRouter routerImplementation = BlastSmartRouter(address(_routerImplementation));
broadcast();
if (forMultisig) {
mgvAmp = new BlastMangroveAmplifier{salt: salt}(mgv, routerProxyFactory, routerImplementation);
mgvAmp = new BlastMangroveAmplifier{salt: salt}({
mgv: mgv,
factory: routerProxyFactory,
routerImplementation: routerImplementation,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
});
} else {
mgvAmp = new BlastMangroveAmplifier(mgv, routerProxyFactory, routerImplementation);
mgvAmp = new BlastMangroveAmplifier({
mgv: mgv,
factory: routerProxyFactory,
routerImplementation: routerImplementation,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
You can specify a mangrove address with the MGV env var.*/
contract MangroveAmplifierDeployer is Deployer {
function run() public {
function run() public virtual {
innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
routerProxyFactory: RouterProxyFactory(envAddressOrName("ROUTER_PROXY_FACTORY", "RouterProxyFactory")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,87 @@ import {Deployer} from "@mgv/script/lib/Deployer.sol";
import {BlastRouterProxyFactory} from "@mgv-strats/src/strategies/chains/blast/routers/BlastRouterProxyFactory.sol";
import {BlastMangroveOrder} from "@mgv-strats/src/strategies/chains/blast/BlastMangroveOrder.sol";

contract BlastMangroveOrderDeployer is MangroveOrderDeployer {
import {BlastSmartRouter} from "@mgv-strats/src/strategies/chains/blast/routers/BlastSmartRouter.sol";

import {SmartRouter} from "@mgv-strats/src/strategies/routers/SmartRouter.sol";
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";

import {StdCheats} from "@mgv/forge-std/StdCheats.sol";

contract BlastMangroveOrderDeployer is MangroveOrderDeployer, StdCheats {
IBlast public blastContract;
IBlastPoints public blastPointsContract;

address public blastGovernor;
address public blastPointsOperator;

function run() public override {
blastContract = IBlast(envAddressOrName("BLAST_CONTRACT", "Blast"));
blastPointsContract = IBlastPoints(envAddressOrName("BLAST_POINTS_CONTRACT", "BlastPoints"));
blastGovernor = envAddressOrName("BLAST_GOVERNOR", "BlastGovernor");
blastPointsOperator = envAddressOrName("BLAST_POINTS_OPERATOR", "BlastPointsOperator");

innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
admin: envAddressOrName("MGV_GOVERNANCE", broadcaster()),
routerProxyFactory: BlastRouterProxyFactory(envAddressOrName("ROUTER_PROXY_FACTORY", "RouterProxyFactory")),
_blastContract: IBlast(envAddressOrName("BLAST_CONTRACT", "Blast")),
_blastPointsContract: IBlastPoints(envAddressOrName("BLAST_POINTS_CONTRACT", "BlastPoints")),
_blastGovernor: envAddressOrName("BLAST_GOVERNOR", "BlastGovernor"),
_blastPointsOperator: envAddressOrName("BLAST_POINTS_OPERATOR", "BlastPointsOperator")
});
outputDeployment();
}

function innerRun(
IMangrove mgv,
address admin,
BlastRouterProxyFactory routerProxyFactory,
IBlast _blastContract,
address _blastGovernor,
IBlastPoints _blastPointsContract,
address _blastPointsOperator
) public {
blastContract = _blastContract;
blastPointsContract = _blastPointsContract;
blastGovernor = _blastGovernor;
blastPointsOperator = _blastPointsOperator;

// forge doesn't know the Blast predeploys, so we need to deploy them.
// Otherwise, the script fails (even with the --skip-simulation flag).
deployCodeTo("Blast.sol", address(blastContract));
deployCodeTo("BlastPoints.sol", address(blastPointsContract));

super.innerRun({mgv: mgv, admin: admin, routerProxyFactory: routerProxyFactory});
}

function deployMangroveOrder(IMangrove mgv, address admin, BlastRouterProxyFactory routerProxyFactory)
internal
virtual
returns (MangroveOrder mgvOrder)
{
broadcast();
if (forMultisig) {
mgvOrder = new BlastMangroveOrder{salt: salt}(mgv, routerProxyFactory, admin);
mgvOrder = new BlastMangroveOrder{salt: salt}({
mgv: mgv,
factory: routerProxyFactory,
deployer: admin,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
});
} else {
mgvOrder = new BlastMangroveOrder(mgv, routerProxyFactory, admin);
mgvOrder = new BlastMangroveOrder({
mgv: mgv,
factory: routerProxyFactory,
deployer: admin,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {Deployer} from "@mgv/script/lib/Deployer.sol";
You can specify a mangrove address with the MGV env var.*/
contract MangroveOrderDeployer is Deployer {
function run() public {
function run() public virtual {
innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
admin: envAddressOrName("MGV_GOVERNANCE", broadcaster()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,43 @@ pragma solidity ^0.8.13;
import {Script, console} from "@mgv/forge-std/Script.sol";
import {BlastRouterProxyFactory} from "@mgv-strats/src/strategies/chains/blast/routers/BlastRouterProxyFactory.sol";
import {Deployer} from "@mgv/script/lib/Deployer.sol";
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";

import {StdCheats} from "@mgv/forge-std/StdCheats.sol";

/* Deploys a BlastRouterProxyFactory instance */
// NB: Must be executed with the --skip-simulation --slow flags:
// - Skip simulation because the Blast predeploys are not known by forge
// - Slow because Blast Sepolia (and maybe Blast) fails to execute transactions
// that interact with a contract that was deployed in the same block.
contract BlastRouterProxyFactoryDeployer is Deployer {
function run() public {
innerRun();
innerRun({
admin: envAddressOrName("ADMIN", broadcaster()),
_blastContract: IBlast(envAddressOrName("BLAST_CONTRACT", "Blast")),
_blastPointsContract: IBlastPoints(envAddressOrName("BLAST_POINTS_CONTRACT", "BlastPoints")),
_blastGovernor: envAddressOrName("BLAST_GOVERNOR", "BlastGovernor"),
_blastPointsOperator: envAddressOrName("BLAST_POINTS_OPERATOR", "BlastPointsOperator")
});
outputDeployment();
}

function innerRun() public {
function innerRun(
address admin,
IBlast _blastContract,
address _blastGovernor,
IBlastPoints _blastPointsContract,
address _blastPointsOperator
) public {
broadcast();
BlastRouterProxyFactory factory = new BlastRouterProxyFactory(broadcaster());
BlastRouterProxyFactory factory = new BlastRouterProxyFactory({
_admin: admin,
_blastContract: _blastContract,
blastGovernor: _blastGovernor,
_blastPointsContract: _blastPointsContract,
_blastPointsOperator: _blastPointsOperator
});
fork.set("RouterProxyFactory", address(factory));
console.log("factory deployed", address(factory));
}
Expand Down
33 changes: 21 additions & 12 deletions src/strategies/chains/blast/BlastMangroveAmplifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@ pragma solidity ^0.8.20;

import {IMangrove} from "@mgv/src/IMangrove.sol";
import {RouterProxyFactory} from "@mgv-strats/src/strategies/offer_forwarder/RenegingForwarder.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";
import {BlastLib} from "@mgv/src/chains/blast/lib/BlastLib.sol";
import {MangroveAmplifier} from "@mgv-strats/src/strategies/MangroveAmplifier.sol";
import {BlastSmartRouter} from "@mgv-strats/src/strategies/chains/blast/routers/BlastSmartRouter.sol";
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";

/// @title BlastMangroveAmplifier
/// @author Mangrove
/// @notice The Blast variant of MangroveAmplifier
contract BlastMangroveAmplifier is MangroveAmplifier, IBlastPoints {
contract BlastMangroveAmplifier is MangroveAmplifier {
///@notice MangroveAmplifier is a Forwarder logic with a smart router.
///@param mgv The mangrove contract on which this logic will run taker and maker orders.
///@param factory the router proxy factory used to deploy or retrieve user routers
///@param routerImplementation the router implementation used to deploy user routers
constructor(IMangrove mgv, RouterProxyFactory factory, BlastSmartRouter routerImplementation)
MangroveAmplifier(mgv, factory, routerImplementation)
{
BlastLib.BLAST.configureGovernor(msg.sender);
}

/// @inheritdoc IBlastPoints
function blastPointsAdmin() external view override returns (address) {
return _admin;
///@param blastContract the Blast contract to use for configuration of claimable yield and gas
///@param blastGovernor the governor to register on the Blast contract
///@param blastPointsContract the BlastPoints contract on which to register the Blast Points operator
///@param blastPointsOperator the operator to register on the BlastPoints contract
///@dev The Blast contract is configured to claimable yield and gas
constructor(
IMangrove mgv,
RouterProxyFactory factory,
BlastSmartRouter routerImplementation,
IBlast blastContract,
address blastGovernor,
IBlastPoints blastPointsContract,
address blastPointsOperator
) MangroveAmplifier(mgv, factory, routerImplementation) {
blastContract.configureClaimableYield();
blastContract.configureClaimableGas();
blastContract.configureGovernor(blastGovernor);
blastPointsContract.configurePointsOperator(blastPointsOperator);
}
}
35 changes: 25 additions & 10 deletions src/strategies/chains/blast/BlastMangroveOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,46 @@ pragma solidity ^0.8.20;

import {IMangrove} from "@mgv/src/IMangrove.sol";
import {RouterProxyFactory} from "@mgv-strats/src/strategies/offer_forwarder/RenegingForwarder.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";
import {BlastLib} from "@mgv/src/chains/blast/lib/BlastLib.sol";
import {MangroveOrder} from "@mgv-strats/src/strategies/MangroveOrder.sol";
import {SmartRouter} from "@mgv-strats/src/strategies/routers/SmartRouter.sol";
import {BlastSmartRouter} from "@mgv-strats/src/strategies/chains/blast/routers/BlastSmartRouter.sol";
import {IBlast} from "@mgv/src/chains/blast/interfaces/IBlast.sol";
import {IBlastPoints} from "@mgv/src/chains/blast/interfaces/IBlastPoints.sol";

import {RenegingForwarder} from "@mgv-strats/src/strategies/offer_forwarder/RenegingForwarder.sol";

/// @title BlastMangroveOrder
/// @author Mangrove
/// @notice The Blast variant of MangroveOrder
contract BlastMangroveOrder is MangroveOrder, IBlastPoints {
contract BlastMangroveOrder is MangroveOrder {
IBlast internal _blast;

///@notice MangroveOrder is a Forwarder logic with a smart router.
///@param mgv The mangrove contract on which this logic will run taker and maker orders.
///@param factory the router proxy factory used to deploy or retrieve user routers
///@param deployer The address of the admin of `this` at the end of deployment
constructor(IMangrove mgv, RouterProxyFactory factory, address deployer) MangroveOrder(mgv, factory, deployer) {
BlastLib.BLAST.configureGovernor(deployer);
///@param blastContract the Blast contract to use for configuration of claimable yield and gas
///@param blastGovernor the governor to register on the Blast contract
///@param blastPointsContract the BlastPoints contract on which to register the Blast Points operator
///@param blastPointsOperator the operator to register on the BlastPoints contract
///@dev The Blast contract is configured to claimable yield and gas
constructor(
IMangrove mgv,
RouterProxyFactory factory,
address deployer,
IBlast blastContract,
address blastGovernor,
IBlastPoints blastPointsContract,
address blastPointsOperator
) MangroveOrder(mgv, factory, deployer) {
blastContract.configureClaimableYield();
blastContract.configureClaimableGas();
blastContract.configureGovernor(blastGovernor);
blastPointsContract.configurePointsOperator(blastPointsOperator);
}

/// @inheritdoc MangroveOrder
function _deploySmartRouter() internal override returns (SmartRouter) {
return new BlastSmartRouter(address(this));
}

/// @inheritdoc IBlastPoints
function blastPointsAdmin() external view override returns (address) {
return _admin;
}
}
Loading

0 comments on commit 4f3b6c9

Please sign in to comment.