Skip to content

Commit

Permalink
Merge pull request #462 from FastLane-Labs/claim-surcharge-on-deploy
Browse files Browse the repository at this point in the history
feat: add surcharge withdrawal to deploy script
  • Loading branch information
BenSparksCode authored Dec 6, 2024
2 parents f21c2d9 + 73132fc commit 853c105
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions script/deploy-atlas.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ contract DeployAtlasScript is DeployBaseScript {
address expectedAtlasVerificationAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 3);
address expectedSimulatorAddr = vm.computeCreateAddress(deployer, vm.getNonce(deployer) + 4);

address prevAtlasAddr = _getAddressFromDeploymentsJson("ATLAS");
uint256 prevSurcharge = (prevAtlasAddr == address(0)) ? 0 : Atlas(payable(prevAtlasAddr)).cumulativeSurcharge();
address prevSimAddr = _getAddressFromDeploymentsJson("SIMULATOR");
uint256 prevSimBalance = (prevSimAddr == address(0)) ? 0 : prevSimAddr.balance;

console.log("Deployer address: \t\t", deployer);
console.log("Prev Simulator balance: \t", prevSimBalance);
console.log("Prev Atlas Gas Surcharge: \t", prevSurcharge);

vm.startBroadcast(deployerPrivateKey);

Expand All @@ -59,6 +62,11 @@ contract DeployAtlasScript is DeployBaseScript {
simulator = new Simulator();
simulator.setAtlas(address(atlas));

// If prev Atlas deployment has surcharge, withdraw it
if (prevAtlasAddr != address(0) && prevSurcharge > 0) {
Atlas(payable(prevAtlasAddr)).withdrawSurcharge();
}

// If prev Simulator deployment has native assets, withdraw them to new Simulator
if (prevSimBalance > 0) {
Simulator(payable(prevSimAddr)).withdrawETH(address(simulator));
Expand Down

0 comments on commit 853c105

Please sign in to comment.