Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: base #775

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 57 additions & 13 deletions script/core/ActivateMarket.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,35 @@ import {ActivateSemibook} from "./ActivateSemibook.s.sol";

contract ActivateMarket is Deployer {
function run() public {
innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
reader: MgvReader(envAddressOrName("MGV_READER", "MgvReader")),
market: Market({
tkn0: envAddressOrName("TKN1"),
tkn1: envAddressOrName("TKN2"),
tickSpacing: vm.envUint("TICK_SPACING")
}),
tkn1_in_Mwei: vm.envUint("TKN1_IN_MWEI"),
tkn2_in_Mwei: vm.envUint("TKN2_IN_MWEI"),
fee: vm.envUint("FEE")
});
uint simple = vm.envUint("SIMPLE");
if (simple == 1) {
simpleInnerRun(
IMangrove(envAddressOrName("MGV", "Mangrove")),
MgvReader(envAddressOrName("MGV_READER", "MgvReader")),
OLKey({
outbound_tkn: envAddressOrName("TKN1"),
inbound_tkn: envAddressOrName("TKN2"),
tickSpacing: vm.envUint("TICK_SPACING")
}),
vm.envUint("FEE"),
vm.envUint("DENSITY96X32_0"),
vm.envUint("DENSITY96X32_1"),
vm.envUint("GASBASE")
);
} else {
innerRun({
mgv: IMangrove(envAddressOrName("MGV", "Mangrove")),
reader: MgvReader(envAddressOrName("MGV_READER", "MgvReader")),
market: Market({
tkn0: envAddressOrName("TKN1"),
tkn1: envAddressOrName("TKN2"),
tickSpacing: vm.envUint("TICK_SPACING")
}),
tkn1_in_Mwei: vm.envUint("TKN1_IN_MWEI"),
tkn2_in_Mwei: vm.envUint("TKN2_IN_MWEI"),
fee: vm.envUint("FEE")
});
}
}

/* Activates a market on mangrove. Two semibooks are activated, one where the first tokens is outbound and the second inbound, and the reverse.
Expand Down Expand Up @@ -72,7 +89,6 @@ contract ActivateMarket is Deployer {
/**
* innerRun with gasprice override to allow requiring a higher density without require more bounties from makers
*/

function innerRun(
IMangrove mgv,
uint gaspriceOverride,
Expand Down Expand Up @@ -100,4 +116,32 @@ contract ActivateMarket is Deployer {

new UpdateMarket().innerRun({reader: reader, market: market});
}

function simpleInnerRun(
IMangrove mgv,
MgvReader reader,
OLKey memory olKey,
uint fee,
uint density96X32_0,
uint density96X32_1,
uint gasbase
) public {
new ActivateSemibook().innerSimpleRun({
mgv: mgv,
olKey: olKey,
fee: fee,
density96X32: density96X32_0,
gasbase: gasbase
});

new ActivateSemibook().innerSimpleRun({
mgv: mgv,
olKey: olKey.flipped(),
fee: fee,
density96X32: density96X32_1,
gasbase: gasbase
});

new UpdateMarket().simpleInnerRun(reader, olKey);
}
}
11 changes: 11 additions & 0 deletions script/core/ActivateSemibook.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ contract ActivateSemibook is Test2, Deployer {
broadcast();
mgv.activate({olKey: olKey, fee: fee, density96X32: density96X32, offer_gasbase: gasbase});
}

function innerSimpleRun(
IMangrove mgv, // the gasprice that is used to compute density. Can be set higher that mangrove's gasprice to avoid dust without impacting user's bounty
OLKey memory olKey,
uint fee,
uint density96X32,
uint gasbase
) public {
broadcast();
mgv.activate({olKey: olKey, fee: fee, density96X32: density96X32, offer_gasbase: gasbase});
}
}
6 changes: 6 additions & 0 deletions script/lib/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {BlastFork} from "@mgv/test/lib/forks/Blast.sol";
import {BlastSepoliaFork} from "@mgv/test/lib/forks/BlastSepolia.sol";
import {ZkevmFork} from "@mgv/test/lib/forks/Zkevm.sol";
import {console2 as console} from "@mgv/forge-std/console2.sol";
import {BaseFork} from "@mgv/test/lib/forks/Base.sol";
import {BaseSepoliaFork} from "@mgv/test/lib/forks/BaseSepolia.sol";

address constant ANVIL_DEFAULT_FIRST_ACCOUNT = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
string constant SINGLETON_FORK = "Deployer:Fork";
Expand Down Expand Up @@ -65,6 +67,8 @@ abstract contract Deployer is Script2 {
fork = new ZkevmFork();
} else if (block.chainid == 1442) {
fork = new TestnetZkevmFork();
} else if (block.chainid == 8453) {
fork = new BaseFork();
} else if (block.chainid == 31337) {
fork = new LocalFork();
} else if (block.chainid == 42161) {
Expand All @@ -73,6 +77,8 @@ abstract contract Deployer is Script2 {
fork = new MumbaiFork();
} else if (block.chainid == 81457) {
fork = new BlastFork();
} else if (block.chainid == 84532) {
fork = new BaseSepoliaFork();
} else if (block.chainid == 11155111) {
fork = new SepoliaFork();
} else if (block.chainid == 168587773) {
Expand Down
6 changes: 6 additions & 0 deletions script/periphery/UpdateMarket.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@mgv/src/periphery/MgvReader.sol";
import {IERC20} from "@mgv/lib/IERC20.sol";
import {Deployer} from "@mgv/script/lib/Deployer.sol";
import "@mgv/lib/Debug.sol";
import "@mgv/src/core/MgvLib.sol";

/* Update market information on MgvReader.

Expand Down Expand Up @@ -37,6 +38,11 @@ contract UpdateMarket is Deployer {
logReaderState("[after script]", reader, market);
}

function simpleInnerRun(MgvReader reader, OLKey memory olKey) public {
Market memory market = Market({tkn0: olKey.outbound_tkn, tkn1: olKey.inbound_tkn, tickSpacing: olKey.tickSpacing});
innerRun(reader, market);
}

function logReaderState(string memory intro, MgvReader reader, Market memory market) internal view {
string memory open = reader.isMarketOpen(market) ? "open" : "closed";
console.log("%s MgvReader sees market as: %s", intro, open);
Expand Down
12 changes: 12 additions & 0 deletions test/lib/forks/Base.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {GenericFork} from "./Generic.sol";

contract BaseFork is GenericFork {
constructor() {
CHAIN_ID = 8453;
NAME = "base";
NETWORK = "base";
}
}
12 changes: 12 additions & 0 deletions test/lib/forks/BaseSepolia.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {GenericFork} from "./Generic.sol";

contract BaseSepoliaFork is GenericFork {
constructor() {
CHAIN_ID = 84532;
NAME = "base sepolia";
NETWORK = "base sepolia";
}
}
Loading