-
Notifications
You must be signed in to change notification settings - Fork 15
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
21 changed files
with
1,320 additions
and
133 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
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 |
---|---|---|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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]" | ||
|
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,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 | ||
}) | ||
) | ||
) | ||
); | ||
} | ||
} | ||
} |
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 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,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; | ||
} |
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,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); | ||
} | ||
} |
Oops, something went wrong.