Skip to content

Commit

Permalink
feat: Update Public Repo (#64)
Browse files Browse the repository at this point in the history
* feat: Add stSyrup to migrator deployment (SC-17424) (#2)

* chore: add stSyrup to migrator deployment

* fix: import paths and ci script

* fix: rename script and fix CI

* chore: add TODO

* chore: remove space

---------

Co-authored-by: 0xfarhaan <59924029+0xfarhaan@users.noreply.github.com>

* chore: Updates to be ready to simulate (SC-17680) (#3)

* wip: update mplv2

* fix: failing tests

* feat: adjust migration deployment

* chore: update formatting

---------

Co-authored-by: 0xfarhaan <59924029+0xfarhaan@users.noreply.github.com>

* feat: update scripts for deployment (SC-17681) (#4)

* feat: update scripts for deployment

* feat: update validation scripts

* chore: remove unused import

* chore: update failing test

* feat: update safe jsons

* feat: update safe jsons

* feat: update safe jsons

* chore: fix formatting

* chore: fix formatting

* chore: fix formatting

* feat: add stSyrup validation

* feat: cleanup comments

* feat: fix to redeploy

* feat: fix to redeploy

* chore: add comment

---------

Co-authored-by: Joao Gabriel Carvalho <jg@jgcarv.com>
  • Loading branch information
0xfarhaan and JGcarv authored Oct 23, 2024
1 parent ae30972 commit 3d9d582
Show file tree
Hide file tree
Showing 26 changed files with 208 additions and 460 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Run forge tests and create gas report.
run: |
set -e
forge build
forge test | tee output.txt
test ${PIPESTATUS[0]} -eq 0
sed -n -e '/^|/p' output.txt > gas.txt
Expand Down Expand Up @@ -90,6 +91,7 @@ jobs:
lcov --remove ./lcov.info -o ./lcov.info.pruned 'tests/*'
env:
FOUNDRY_PROFILE: ${{ github.event_name == 'push' && 'ci' || '' }}
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}

- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "modules/address-registry"]
path = modules/address-registry
url = git@github.com:maple-labs/address-registry.git
[submodule "modules/xmpl"]
path = modules/xmpl
url = git@github.com:maple-labs/xMPL.git
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ verify-sanity:
@certora/scripts/verify-sanity.sh

warp:
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"evm_increaseTime","params":[$(secs)]}' $(ETH_RPC_URL)
@scripts/simpleTransaction.sh
10 changes: 5 additions & 5 deletions contracts/MapleTokenInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import { IMapleTokenInitializer } from "./interfaces/IMapleTokenInitializer.sol"

contract MapleTokenInitializer is IMapleTokenInitializer, ERC20Proxied {

uint256 internal constant INITIAL_MINT_MIGRATOR = 10_000_000e18;
uint256 internal constant INITIAL_MINT_TREASURY = 1_000_000e18;
uint256 internal constant INITIAL_MINT_MIGRATOR = 1_000_000_000e18;
uint256 internal constant INITIAL_MINT_TREASURY = 154_930_098e18;

function initialize(address migrator_, address treasury_) external {
name = "Maple Token";
symbol = "MPL";
name = "Syrup Token";
symbol = "SYRUP";
decimals = 18;

emit Initialized(migrator_, treasury_);

_mint(migrator_, INITIAL_MINT_MIGRATOR);
_mint(treasury_, INITIAL_MINT_TREASURY);
_mint(treasury_, INITIAL_MINT_TREASURY );
}

}
4 changes: 4 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ gas_limit = "18446744073709551615"
verbosity = 3
gas_reports = ["EmergencyModule", "RecapitalizationModule", "MapleTokenProxy"]

[profile.production]
optimizer = true
optimizer_runs = 200

[profile.default.fuzz]
runs = 1_000

Expand Down
1 change: 1 addition & 0 deletions modules/xmpl
Submodule xmpl added at 13c098
24 changes: 0 additions & 24 deletions scripts/DeployMigrator.s.sol

This file was deleted.

31 changes: 31 additions & 0 deletions scripts/DeployMigratorAndStsyrup.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

import { console2 as console, Script } from "../modules/forge-std/src/Script.sol";

import { Migrator } from "../modules/migrator/contracts/Migrator.sol";
import { xMPL } from "../modules/xmpl/contracts/xMPL.sol";

contract DeployMigratorAndStsyrup is Script {

function run() external {
address ETH_SENDER = vm.envAddress("ETH_SENDER");

address governor = 0xd6d4Bcde6c816F17889f1Dd3000aF0261B03a196;
address mplv1 = 0x33349B282065b0284d756F0577FB39c158F935e6;
address globals = 0x804a6F5F667170F545Bf14e5DDB48C70B788390C;
address syrup = computeCreateAddress(ETH_SENDER, 2); // 0x643C4E15d7d62Ad0aBeC4a9BD4b001aA3Ef52d66

vm.startBroadcast(ETH_SENDER);
address migrator = address(new Migrator(globals, mplv1, syrup, 100));
console.log("Migrator: %s", migrator);

address stSyrup = address(new xMPL("Staked Syrup", "stSYRUP", governor, syrup, 18));
console.log("stSYRUP: %s", stSyrup);

vm.stopBroadcast();

}

}

10 changes: 5 additions & 5 deletions scripts/DeployToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ contract DeployToken is Script {
address ETH_SENDER = vm.envAddress("ETH_SENDER");

address mapleGlobals = 0x804a6F5F667170F545Bf14e5DDB48C70B788390C;
address migrator = computeCreateAddress(ETH_SENDER, 4); // 0x7b0267C13B994cdb58b8ED3a65b7A09a07432A76,
address migrator = computeCreateAddress(ETH_SENDER, 4); // 0x9c9499edD0cd2dCBc3C9Dd5070bAf54777AD8F2C

vm.startBroadcast(ETH_SENDER);

address tokenImplementation = address(new MapleToken());
address tokenInitializer = address(new MapleTokenInitializer());

console.log("Token Implementation: %s", tokenImplementation);
console.log("Token Initializer: %s", tokenInitializer);
console.log("Token Implementation: %s", tokenImplementation);
console.log("Token Initializer: %s", tokenInitializer);

address tokenProxy = address(new MapleTokenProxy(mapleGlobals, tokenImplementation, tokenInitializer, migrator));

console.log("Token Proxy: %s", tokenProxy);
console.log("Token Proxy: %s", tokenProxy);

address recapitalizationModule = address(new RecapitalizationModule(tokenProxy));

console.log("Recapitalization Module: %s", recapitalizationModule);
console.log("Recapitalization Module: %s", recapitalizationModule);

vm.stopBroadcast();
}
Expand Down
14 changes: 7 additions & 7 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ FOUNDRY_PROFILE=production
# NOTE: Make sure that the computed addresses for mplv2 and migrator are corret for the given ETH_SENDER

# Deploy the token first, listing to mainnet rpc endpoint
forge script \
--rpc-url $ETH_RPC_URL -vvvv \
--sender $ETH_SENDER \
"scripts/DeployToken.s.sol:DeployToken" \
--broadcast --slow --mnemonic-indexes 4 --ledger --gas-estimate-multiplier 200
# forge script \
# --rpc-url $ETH_RPC_URL -vvvv \
# --sender $ETH_SENDER \
# "scripts/DeployToken.s.sol:DeployToken" \
# --broadcast --slow --mnemonic-indexes 13 --ledger --gas-estimate-multiplier 200

# Deploy the migrator next, building on top of the token deployment
forge script \
--rpc-url $ETH_RPC_URL -vvvv \
--sender $ETH_SENDER \
"scripts/DeployMigrator.s.sol:DeployMigrator" \
--broadcast --slow --mnemonic-indexes 4 --ledger --gas-estimate-multiplier 200
"scripts/DeployMigratorAndStsyrup.s.sol:DeployMigratorAndStsyrup" \
--broadcast --slow --mnemonic-indexes 13 --ledger --gas-estimate-multiplier 200
2 changes: 1 addition & 1 deletion scripts/localDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ forge script \
forge script \
--rpc-url "http://localhost:8545" -vvv \
--sender $ETH_SENDER \
"scripts/DeployMigrator.s.sol:DeployMigrator" \
"scripts/DeployMigratorAndStsyrup.s.sol:DeployMigratorAndStsyrup" \
--broadcast --unlocked # --mnemonics foo --mnemonic-indexes 3 --ledger

# Kill the anvil process
Expand Down
20 changes: 20 additions & 0 deletions scripts/simpleTransaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Needed to forward time to pass the timelock on a fork
source ./.env

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"evm_increaseTime","params":[604900]}' $ETH_RPC_URL

curl -X POST $ETH_RPC_URL \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_sendTransaction",
"params": [{
"from": "0x763aC43aFEE020c2670dF03800541B76c8D87882",
"to": "0x0000000000000000000000000000000000000000",
"value": "0x1BC16D674EC80000",
"gas": "0x5208",
"gasPrice": "0x3B9ACA00"
}],
"id": 1
}'
83 changes: 0 additions & 83 deletions tests/e2e/MigrationAndLifecycle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,86 +107,3 @@ contract LifecycleBase is ModuleInvariants {
}

}

contract xMPLMigration is LifecycleBase {

function setUp() public virtual {
vm.createSelectFork(vm.envString("ETH_RPC_URL"), 17622100);

_claimer = makeAddr("claimer");
_governor = makeAddr("governor");
_migratorAddress = makeAddr("migrator");
_treasury = makeAddr("treasury");

_globals = IGlobalsLike(address(new NonTransparentProxy(_governor, deployGlobals())));
_token = IMapleToken(address(new MapleTokenProxy(address(_globals), address(new MapleToken()), address(new MapleTokenInitializer()), _migratorAddress)));
_migrator = IMigrator(deployMigrator(address(oldToken), address(_token)));

_emergencyModule = new EmergencyModule(address(_globals), address(_token));
_recapitalizationModule = new RecapitalizationModule(address(_token));

healthChecker = new RecapitalizationModuleHealthChecker();

configureContracts();
setupHandlers();

start = block.timestamp;
}

function test_e2e_lifecycle(uint256 seed) external {
migrateXmpl();
runLifecycle(seed);
}

/**************************************************************************************************************************************/
/*** Helper Functions ***/
/**************************************************************************************************************************************/

function migrateXmpl() internal {
address owner = _xmpl.owner();
// Schedule migration on xMPL contract
vm.prank(owner);
_xmpl.scheduleMigration(address(_migrator), address(_token));

vm.warp(start + 864000 + 1 seconds);

vm.prank(owner);
_xmpl.performMigration();
}

function deployMigrator(address oldToken_, address newToken_) internal returns (address migratorAddress_) {
address deployedAddress = deployCode("Migrator.sol", abi.encode(oldToken_, newToken_));
migratorAddress_ = _migratorAddress;

// Using etch to always get a deterministic address for the migrator
vm.etch(migratorAddress_, deployedAddress.code);
}

function configureContracts() internal {
vm.startPrank(_governor);

_globals.setMapleTreasury(_treasury);
_globals.setValidInstanceOf("RECAPITALIZATION_CLAIMER", _claimer, true);

_globals.scheduleCall(
address(_token),
"MT:ADD_MODULE",
abi.encodeWithSelector(IMapleToken.addModule.selector, address(_emergencyModule))
);

_token.addModule(address(_emergencyModule));

_globals.scheduleCall(
address(_token),
"MT:ADD_MODULE",
abi.encodeWithSelector(IMapleToken.addModule.selector, address(_recapitalizationModule))
);

_token.addModule(address(_recapitalizationModule));

_globals.setDefaultTimelockParameters(7 days, 2 days);

vm.stopPrank();
}

}
Loading

0 comments on commit 3d9d582

Please sign in to comment.