Skip to content

Commit

Permalink
Release develop to master (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
espendk authored Feb 28, 2024
2 parents 5de47e8 + b664dae commit d18bf5c
Show file tree
Hide file tree
Showing 21 changed files with 1,320 additions and 133 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/publish-npm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# From the master branch, package bumps can be patch, minor, or major.
#
# From the develop branch, package bumps can only be prerelease
# From the develop branch, package bumps can only be prerelease, prepatch, preminor, or premajor.
name: "Publish npm package"

on:
Expand All @@ -14,8 +14,10 @@ on:
default: 'prerelease'
type: choice
options:
- test
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Next version

## Blast support

- Add support for Blast Sepolia
- Add Blast specific contracts, in particular `BlastMangrove` which extends `Mangrove` with support for Blast yield, gas fees, and Blast Points
- Configure Blast Points operator on deployment of `BlastMangrove`
- Configure claimable yield and gas fees on deployment of `BlastMangrove`

## Dependencies

- Upgrade to @mangrovedao/mangrove-deployments v2.1.1
- Upgrade to @mangrovedao/context-addresses v1.2.0
- Upgrade to @mangrovedao/context-addresses v1.3.0
- Simplify copying of context addresses
- Add support for Blast Sepolia

# 2.0.3

Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The files in this repo are covered by different licenses:
integrating with Mangrove) is licensed under the MIT License.
* OpenZeppelin code in ERC20.sol and ERC20Lib.sol is covered by the original
MIT License (text included below).
* Blast.sol code is Licenced under BSL 1.1 - Copyright 2024 MetaLayer Labs Ltd.

Each file header contains the SPDX license identifier of the license for that file.
For more information about SPDX, please refer to <https://spdx.dev/>.
Expand Down
3 changes: 3 additions & 0 deletions checkNatspec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
This script verifies that select files have natspec comments for all parameters and return values of functions
*/

// TODO: In forge 0.2.0 (d58ab7f 2024-02-27T00:16:43.649244000Z), this script no longer works:
// The generated JSON files no longer have an AST field.

const fs = require("fs");
const path = require("path");
const cwd = process.cwd();
Expand Down
8 changes: 6 additions & 2 deletions copyContextAddresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ function getOrCreateNetworkAddresses(networkName) {
return networkAddresses;
}

// Accounts
// Accounts & Blast addresses
const allAccounts = contextAddresses.getAllAccounts();
const allBlastAddresses = contextAddresses.getAllBlastAddresses();
for (const [networkName, namedAddresses] of Object.entries(
contextAddresses.toNamedAddressesPerNamedNetwork(allAccounts),
contextAddresses.toNamedAddressesPerNamedNetwork(
allAccounts,
allBlastAddresses,
),
)) {
const networkAddresses = getOrCreateNetworkAddresses(networkName);
networkAddresses.push(...namedAddresses);
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mangrovedao/mangrove-core",
"version": "2.0.3",
"version": "2.1.0-0",
"author": "Mangrove DAO",
"license": "SEE LICENSE IN LICENSE",
"main": "index.js",
Expand All @@ -11,7 +11,7 @@
"postpack": "pinst --enable",
"postinstall": "husky install",
"corecov": "forge coverage --match-path 'test/core/*'",
"build": "yarn run copyDeploymentAddresses && yarn run copyContextAddresses && forge build && node copyArtifacts && node buildIndex && node checkNatspec",
"build": "yarn run copyDeploymentAddresses && yarn run copyContextAddresses && forge build && node copyArtifacts && node buildIndex",
"clean": "forge clean; rimraf index.js dist",
"doc": "solcco -f doc/MgvDoc.html preprocessing/structs.ts lib/core/Constants.sol src/core/MgvLib.sol src/core/MgvCommon.sol src/core/MgvHasOffers.sol src/core/MgvOfferMaking.sol src/core/MgvOfferTaking.sol src/core/MgvOfferTakingWithPermit.sol src/core/MgvGovernable.sol src/core/MgvView.sol src/core/MgvAppendix.sol src/core/Mangrove.sol lib/core/DensityLib.sol lib/core/TickTreeLib.sol lib/core/TickLib.sol lib/core/BitLib.sol lib/core/OfferExtra.sol lib/core/OfferDetailExtra.sol lib/core/LocalExtra.sol",
"copyDeploymentAddresses": "node copyDeploymentAddresses",
Expand Down Expand Up @@ -42,22 +42,22 @@
"gas-measurement.sh"
],
"devDependencies": {
"@mangrovedao/context-addresses": "^1.2.0",
"@mangrovedao/context-addresses": "^1.3.0",
"@mangrovedao/mangrove-deployments": "^2.1.1",
"@types/node": "^20.9.0",
"@types/node": "^20.11.5",
"bn.js": "^5.2.1",
"husky": "^8.0.3",
"lint-staged": "^15.1.0",
"mathjs": "^12.0.0",
"lint-staged": "^15.2.0",
"mathjs": "^12.3.0",
"micromatch": "^4.0.5",
"pinst": "^3.0.0",
"prettier": "^3.1.0",
"rimraf": "^5.0.5",
"shelljs": "^0.8.4",
"solcco": ">=1.0.13",
"solhint": "^4.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"yargs": "^17.7.2"
},
"packageManager": "[email protected]"
Expand Down
102 changes: 102 additions & 0 deletions script/core/deployers/BlastMangroveDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {BlastMangrove} from "@mgv/src/chains/blast/core/BlastMangrove.sol";
import {IBlastMangrove} from "@mgv/src/chains/blast/IBlastMangrove.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";

import {MangroveDeployer} from "./MangroveDeployer.s.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 BlastMangroveDeployer is MangroveDeployer, 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({
chief: envAddressOrName("CHIEF", broadcaster()),
gasprice: envHas("GASPRICE") ? vm.envUint("GASPRICE") : 1,
gasmax: envHas("GASMAX") ? vm.envUint("GASMAX") : 2_000_000,
gasbot: envAddressOrName("GASBOT", "Gasbot"),
_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(
address chief,
uint gasprice,
uint gasmax,
address gasbot,
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(chief, gasprice, gasmax, gasbot);
}

function deployMangrove(address governance, uint gasprice, uint gasmax) public override {
broadcast();
if (forMultisig) {
mgv = IBlastMangrove(
payable(
address(
new BlastMangrove{salt: salt}({
governance: governance,
gasprice: gasprice,
gasmax: gasmax,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
})
)
)
);
} else {
mgv = IBlastMangrove(
payable(
address(
new BlastMangrove({
governance: governance,
gasprice: gasprice,
gasmax: gasmax,
blastContract: blastContract,
blastGovernor: blastGovernor,
blastPointsContract: blastPointsContract,
blastPointsOperator: blastPointsOperator
})
)
)
);
}
}
}
32 changes: 0 additions & 32 deletions script/core/deployers/BlastSepoliaMangroveDeployer.s.sol

This file was deleted.

24 changes: 14 additions & 10 deletions script/core/deployers/MangroveDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract MangroveDeployer is Deployer {
MgvReader public reader;
MgvOracle public oracle;

function run() public {
function run() public virtual {
innerRun({
chief: envAddressOrName("CHIEF", broadcaster()),
gasprice: envHas("GASPRICE") ? vm.envUint("GASPRICE") : 1,
Expand All @@ -23,7 +23,7 @@ contract MangroveDeployer is Deployer {
outputDeployment();
}

function innerRun(address chief, uint gasprice, uint gasmax, address gasbot) public {
function innerRun(address chief, uint gasprice, uint gasmax, address gasbot) public virtual {
broadcast();
if (forMultisig) {
oracle = new MgvOracle{salt: salt}({governance_: chief, initialMutator_: gasbot, initialGasPrice_: gasprice});
Expand All @@ -32,14 +32,7 @@ contract MangroveDeployer is Deployer {
}
fork.set("MgvOracle", address(oracle));

broadcast();
if (forMultisig) {
mgv = IMangrove(
payable(address(new Mangrove{salt: salt}({governance: broadcaster(), gasprice: gasprice, gasmax: gasmax})))
);
} else {
mgv = IMangrove(payable(address(new Mangrove({governance: broadcaster(), gasprice: gasprice, gasmax: gasmax}))));
}
deployMangrove(broadcaster(), gasprice, gasmax);
fork.set("Mangrove", address(mgv));

broadcast();
Expand All @@ -52,4 +45,15 @@ contract MangroveDeployer is Deployer {
(new MgvReaderDeployer()).innerRun(mgv);
reader = MgvReader(fork.get("MgvReader"));
}

function deployMangrove(address governance, uint gasprice, uint gasmax) public virtual {
broadcast();
if (forMultisig) {
mgv = IMangrove(
payable(address(new Mangrove{salt: salt}({governance: governance, gasprice: gasprice, gasmax: gasmax})))
);
} else {
mgv = IMangrove(payable(address(new Mangrove({governance: governance, gasprice: gasprice, gasmax: gasmax}))));
}
}
}
20 changes: 20 additions & 0 deletions src/chains/blast/IBlastMangrove.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {IMangrove} from "../../IMangrove.sol";

/// @title IBlastMangrove
/// @notice Interface implemented by BlastMangrove.
interface IBlastMangrove is IMangrove {
/// @notice Change the Blast governor.
/// @param governor The new governor address.
/// @dev Only Mangrove governance can call this function.
/// @dev This ensures that Mangrove governance can always change the governor.
function configureBlastGovernor(address governor) external;

/// @notice Change the BlastPoints operator.
/// @param operator The new operator address
/// @dev Only Mangrove governance can call this function.
/// @dev This ensures that Mangrove governance can always change the operator.
function configureBlastPointsOperator(address operator) external;
}
36 changes: 36 additions & 0 deletions src/chains/blast/core/BlastMangrove.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.10;

import {Mangrove} from "../../../core/Mangrove.sol";
import {IBlast} from "../interfaces/IBlast.sol";
import {IBlastPoints} from "../interfaces/IBlastPoints.sol";

/// @title BlastMangrove
/// @notice Mangrove extension that adds support for Blast yield and points.
/// @dev ETH yield MUST NOT use automatic mode as governance has no way to extract the yield.
/// This is a security measure, as governance would otherwise be able to steal users'
/// provisions which are stored on Mangrove.
/// @dev As for ETH yield, gas fees MUST NOT be stored on the contract.
// Automatic claiming of gas fees is not currently supported, so not an issue in practice.
/// @dev WETH and USDB can safely use automatic mode as fees are already stored on the contract
/// and extractable by governance.
contract BlastMangrove is Mangrove {
constructor(
address governance,
uint gasprice,
uint gasmax,
IBlast blastContract,
address blastGovernor,
IBlastPoints blastPointsContract,
address blastPointsOperator
) Mangrove(governance, gasprice, gasmax) {
// Ensure yield and gas fees are claimable by `blastGovernor`
// NB: ETH yield MUST NOT use automatic mode as governance has no way to extract the yield.
blastContract.configureClaimableYield();

blastContract.configureClaimableGas();
blastContract.configureGovernor(blastGovernor);

blastPointsContract.configurePointsOperator(blastPointsOperator);
}
}
Loading

0 comments on commit d18bf5c

Please sign in to comment.