Skip to content

Commit

Permalink
Fix: Better script structure (#88)
Browse files Browse the repository at this point in the history
* fix: better script structure

* fix: add new ABI

* fix: add default MgvArbitrage to ativate script

* fix: UNLICENSED to Unlicense

Co-authored-by: Espen Højsgaard <[email protected]>

* fix: correct license on scripts

* fix: all UNLICENSED to Unlicense

---------

Co-authored-by: Espen Højsgaard <[email protected]>
  • Loading branch information
peterMangrove and espendk authored Jun 29, 2023
1 parent 0581027 commit 5f5da0c
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 34 deletions.
39 changes: 39 additions & 0 deletions packages/mangrove-arbitrage/abi/MgvArbitrage.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "router",
"outputs": [
{
"internalType": "contract ISwapRouter",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand All @@ -301,6 +314,32 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newArbitrager",
"type": "address"
}
],
"name": "setArbitrager",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IMangrove",
"name": "newMgv",
"type": "address"
}
],
"name": "setMgv",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import {Deployer} from "mgv_script/lib/Deployer.sol";
Expand All @@ -13,7 +13,7 @@ contract MgvArbitrageActivateTokens is Deployer {
innerRun({
tkn1: IERC20(envAddressOrName("TKN1")),
tkn2: IERC20(envAddressOrName("TKN2")),
arbitrageContract: envAddressOrName("ARBITRAGECONTRACT")
arbitrageContract: envAddressOrName("ARBITRAGECONTRACT", "MgvArbitrage")
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import {Deployer} from "mgv_script/lib/Deployer.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import {Deployer} from "mgv_script/lib/Deployer.sol";
Expand All @@ -10,7 +10,7 @@ contract MgvArbitrageDeployer is Deployer {

function run() public {
innerRun({
admin: envAddressOrName("CHIEF"),
admin: envAddressOrName("CHIEF", broadcaster()),
arbitrager: envAddressOrName("ARBITRAGER"),
mgv: envAddressOrName("MGV", "Mangrove")
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import {Deployer} from "mgv_script/lib/Deployer.sol";
import {MgvArbitrageDeployer} from "script/deployers/MgvArbitrageDeployer.s.sol";

contract MumbaiMgvArbitrageDeployer is Deployer {
MgvArbitrageDeployer public arbDeployer;

function run() public {
runWithChainSpecificParams();
outputDeployment();
}

function runWithChainSpecificParams() public {
arbDeployer = new MgvArbitrageDeployer();
arbDeployer.innerRun({
admin: broadcaster(),
arbitrager: envAddressOrName("ARBITRAGER", "Arbitrager"),
mgv: envAddressOrName("MGV", "Mangrove")
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.13;

import {Deployer} from "mgv_script/lib/Deployer.sol";
import {MgvArbitrageDeployer} from "script/deployers/MgvArbitrageDeployer.s.sol";

contract PolygonMgvArbitrageDeployer is Deployer {
MgvArbitrageDeployer public arbDeployer;

function run() public {
runWithChainSpecificParams();
outputDeployment();
}

function runWithChainSpecificParams() public {
arbDeployer = new MgvArbitrageDeployer();
arbDeployer.innerRun({
admin: broadcaster(),
arbitrager: envAddressOrName("ARBITRAGER", "Arbitrager"),
mgv: envAddressOrName("MGV", "Mangrove")
});
}
}
2 changes: 1 addition & 1 deletion packages/mangrove-arbitrage/src/MyPinnedPolygon.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {GenericFork} from "mgv_test/lib/forks/Generic.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/mangrove-arbitrage/test/MgvArbitrage.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {MangroveTest} from "mgv_test/lib/MangroveTest.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {Deployer} from "mgv_script/lib/Deployer.sol";
import {MgvArbitrageActivateTokens} from "script/MgvArbitrageActivateTokens.s.sol";
import {MgvArbitrageDeployer} from "script/MgvArbitrageDeployer.s.sol";
import {MgvArbitrageDeployer} from "script/deployers/MgvArbitrageDeployer.s.sol";
import {IERC20} from "mgv_src/IERC20.sol";
import "mgv_test/lib/forks/Polygon.sol";
import {MangroveJsDeploy} from "mgv_script/toy/MangroveJs.s.sol";
Expand Down
25 changes: 0 additions & 25 deletions packages/mangrove-arbitrage/test/MgvArbitrageDeployerTest.t.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {Deployer} from "mgv_script/lib/Deployer.sol";
import {MangroveDeployer} from "mgv_script/core/deployers/MangroveDeployer.s.sol";
import {MgvArbitrageDeployer} from "script/deployers/MgvArbitrageDeployer.s.sol";

import {Test2, Test} from "mgv_lib/Test2.sol";

abstract contract BaseMgvArbitrageDeployerTest is Deployer, Test2 {
MgvArbitrageDeployer mgvArbDeployer;
MangroveDeployer mgvDeployer;
address admin;
address arbitrager;

function test_toy_ens_has_addresses() public {
assertEq(mgvArbDeployer.mgvArb().arbitrager(), arbitrager, "Wrong arbitrager address");
assertEq(mgvArbDeployer.mgvArb().admin(), admin, "Wrong admin address");
assertEq(address(mgvArbDeployer.mgvArb().mgv()), fork.get("Mangrove"), "Wrong mgv address");
assertEq(fork.get("MgvArbitrage"), address(mgvArbDeployer.mgvArb()), "MgvArbitrage address not correct");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {MangroveDeployer} from "mgv_script/core/deployers/MangroveDeployer.s.sol";
import {MgvArbitrageDeployer} from "script/deployers/MgvArbitrageDeployer.s.sol";
import {BaseMgvArbitrageDeployerTest} from "test/deployers/BaseMgvArbitrageDeployerTest.t.sol";

import {Test2, Test} from "mgv_lib/Test2.sol";

contract MgvArbitrageDeployerTest is BaseMgvArbitrageDeployerTest {
function setUp() public {
arbitrager = freshAddress("arbitrager");
admin = freshAddress("chief");

mgvDeployer = new MangroveDeployer();
mgvDeployer.innerRun({chief: admin, gasprice: 1, gasmax: 2_000_000, gasbot: address(0)});
mgvArbDeployer = new MgvArbitrageDeployer();
mgvArbDeployer.innerRun({admin: admin, arbitrager: arbitrager, mgv: address(mgvDeployer.mgv())});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {MangroveDeployer} from "mgv_script/core/deployers/MangroveDeployer.s.sol";
import {MumbaiMgvArbitrageDeployer} from "script/deployers/MumbaiMgvArbitrageDeployer.s.sol";
import {BaseMgvArbitrageDeployerTest} from "test/deployers/BaseMgvArbitrageDeployerTest.t.sol";

import {Test2, Test} from "mgv_lib/Test2.sol";

contract MumbaiMgvArbitrageDeployerTest is BaseMgvArbitrageDeployerTest {
function setUp() public {
admin = broadcaster();
arbitrager = freshAddress("arbitrager");
fork.set("Arbitrager", arbitrager);

mgvDeployer = new MangroveDeployer();
mgvDeployer.innerRun({chief: admin, gasprice: 1, gasmax: 2_000_000, gasbot: address(0)});
MumbaiMgvArbitrageDeployer mumbaiMgvArbitrageDeployer = new MumbaiMgvArbitrageDeployer();

mumbaiMgvArbitrageDeployer.runWithChainSpecificParams();

mgvArbDeployer = mumbaiMgvArbitrageDeployer.arbDeployer();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.10;

import {MangroveDeployer} from "mgv_script/core/deployers/MangroveDeployer.s.sol";
import {PolygonMgvArbitrageDeployer} from "script/deployers/PolygonMgvArbitrageDeployer.s.sol";
import {BaseMgvArbitrageDeployerTest} from "test/deployers/BaseMgvArbitrageDeployerTest.t.sol";

import {Test2, Test} from "mgv_lib/Test2.sol";

contract PolygonMgvArbitrageDeployerTest is BaseMgvArbitrageDeployerTest {
function setUp() public {
admin = broadcaster();
arbitrager = freshAddress("arbitrager");
fork.set("Arbitrager", arbitrager);

mgvDeployer = new MangroveDeployer();
mgvDeployer.innerRun({chief: admin, gasprice: 1, gasmax: 2_000_000, gasbot: address(0)});

PolygonMgvArbitrageDeployer polygonMgvArbitrageDeployer = new PolygonMgvArbitrageDeployer();

polygonMgvArbitrageDeployer.runWithChainSpecificParams();

mgvArbDeployer = polygonMgvArbitrageDeployer.arbDeployer();
}
}

0 comments on commit 5f5da0c

Please sign in to comment.