Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fxp3 committed Mar 19, 2024
1 parent ae7faa3 commit 299c993
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 197 deletions.
2 changes: 1 addition & 1 deletion lib/kresko-foundry-helpers
19 changes: 10 additions & 9 deletions src/contracts/core/vendor/pyth/PythScript.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {VM} from "kresko-lib/utils/LibVm.s.sol";
import {vmFFI} from "kresko-lib/utils/Base.s.sol";

import {IPyth} from "vendor/pyth/IPyth.sol";
import {JSON} from "scripts/deploy/libs/LibJSON.s.sol";

Expand All @@ -22,10 +23,10 @@ function getPythData(bytes32[] memory _ids) returns (bytes[] memory) {
args[1] = "--no-warnings";
args[2] = "utils/pythPayload.js";
for (uint256 i = 0; i < _ids.length; i++) {
args[i + 3] = VM.toString(_ids[i]);
args[i + 3] = vmFFI.toString(_ids[i]);
}

(, bytes[] memory updatedata, ) = abi.decode(VM.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
(, bytes[] memory updatedata, ) = abi.decode(vmFFI.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
return updatedata;
}

Expand All @@ -40,10 +41,10 @@ function getPythData(JSON.Config memory cfg) returns (bytes[] memory) {
args[1] = "--no-warnings";
args[2] = "utils/pythPayload.js";
for (uint256 i = 0; i < _assets.length; i++) {
args[i + 3] = VM.toString(_assets[i]);
args[i + 3] = vmFFI.toString(_assets[i]);
}

(, bytes[] memory updatedata, ) = abi.decode(VM.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
(, bytes[] memory updatedata, ) = abi.decode(vmFFI.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
return updatedata;
}

Expand All @@ -56,7 +57,7 @@ function getPythData(string memory _ids) returns (bytes[] memory, PythView memor
args[3] = _ids;

(bytes32[] memory ids, bytes[] memory updatedata, IPyth.Price[] memory prices) = abi.decode(
VM.ffi(args),
vmFFI.ffi(args),
(bytes32[], bytes[], IPyth.Price[])
);
return (updatedata, PythView(ids, prices));
Expand All @@ -76,10 +77,10 @@ function getPythViewData(bytes32[] memory _ids) returns (PythView memory result)
args[1] = "--no-warnings";
args[2] = "utils/pythPayload.js";
for (uint256 i = 0; i < _ids.length; i++) {
args[i + 3] = VM.toString(_ids[i]);
args[i + 3] = vmFFI.toString(_ids[i]);
}

(bytes32[] memory ids, , IPyth.Price[] memory prices) = abi.decode(VM.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
(bytes32[] memory ids, , IPyth.Price[] memory prices) = abi.decode(vmFFI.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
return PythView(ids, prices);
}

Expand All @@ -102,6 +103,6 @@ function getPythViewData(string memory _ids) returns (PythView memory result) {
args[2] = "utils/pythPayload.js";
args[3] = _ids;

(bytes32[] memory ids, , IPyth.Price[] memory prices) = abi.decode(VM.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
(bytes32[] memory ids, , IPyth.Price[] memory prices) = abi.decode(vmFFI.ffi(args), (bytes32[], bytes[], IPyth.Price[]));
return PythView(ids, prices);
}
4 changes: 2 additions & 2 deletions src/contracts/scripts/deploy/libs/Deployed.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {VM, Help} from "kresko-lib/utils/Libs.s.sol";
import {Help, mvm} from "kresko-lib/utils/Libs.s.sol";
import {Asset} from "common/Types.sol";
import {IDeploymentFactory} from "factory/IDeploymentFactory.sol";

Expand Down Expand Up @@ -31,7 +31,7 @@ library Deployed {
args[3] = name;
args[4] = chainId.str();

return VM.ffi(args).str().toAddr();
return mvm.ffi(args).str().toAddr();
}

function cache(string memory id, address _addr) internal returns (address) {
Expand Down
22 changes: 11 additions & 11 deletions src/contracts/scripts/deploy/libs/LibDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {DataV1} from "periphery/DataV1.sol";
import {KrMulticall} from "periphery/KrMulticall.sol";
import {Role} from "common/Constants.sol";
import {IKresko} from "periphery/IKresko.sol";
import {Help, Log, VM} from "kresko-lib/utils/Libs.s.sol";
import {Help, Log, mvm} from "kresko-lib/utils/Libs.s.sol";
import {GatingManager} from "periphery/GatingManager.sol";
import {Deployed} from "scripts/deploy/libs/Deployed.s.sol";
import {CONST} from "scripts/deploy/CONST.s.sol";
Expand Down Expand Up @@ -267,18 +267,18 @@ library LibDeploy {
}

function initOutputJSON(string memory configId) internal {
string memory outputDir = string.concat("./out/foundry/deploy/", VM.toString(block.chainid), "/");
if (!VM.exists(outputDir)) VM.createDir(outputDir, true);
string memory outputDir = string.concat("./out/foundry/deploy/", mvm.toString(block.chainid), "/");
if (!mvm.exists(outputDir)) mvm.createDir(outputDir, true);
state().id = configId;
state().outputLocation = outputDir;
state().outputJson = configId;
}

function writeOutputJSON() internal {
string memory runsDir = string.concat(state().outputLocation, "runs/");
if (!VM.exists(runsDir)) VM.createDir(runsDir, true);
VM.writeFile(string.concat(runsDir, state().id, "-", VM.toString(VM.unixTime()), ".json"), state().outputJson);
VM.writeFile(string.concat(state().outputLocation, state().id, "-", "latest", ".json"), state().outputJson);
if (!mvm.exists(runsDir)) mvm.createDir(runsDir, true);
mvm.writeFile(string.concat(runsDir, state().id, "-", mvm.toString(mvm.unixTime()), ".json"), state().outputJson);
mvm.writeFile(string.concat(state().outputLocation, state().id, "-", "latest", ".json"), state().outputJson);
}

function state() internal pure returns (DeployState storage ds) {
Expand All @@ -300,23 +300,23 @@ library LibDeploy {
}

function setJsonAddr(string memory key, address val) internal {
state().currentJson = VM.serializeAddress(state().currentKey, key, val);
state().currentJson = mvm.serializeAddress(state().currentKey, key, val);
}

function setJsonBool(string memory key, bool val) internal {
state().currentJson = VM.serializeBool(state().currentKey, key, val);
state().currentJson = mvm.serializeBool(state().currentKey, key, val);
}

function setJsonNumber(string memory key, uint256 val) internal {
state().currentJson = VM.serializeUint(state().currentKey, key, val);
state().currentJson = mvm.serializeUint(state().currentKey, key, val);
}

function setJsonBytes(string memory key, bytes memory val) internal {
state().currentJson = VM.serializeBytes(state().currentKey, key, val);
state().currentJson = mvm.serializeBytes(state().currentKey, key, val);
}

function saveJSONKey() internal {
state().outputJson = VM.serializeString("out", state().currentKey, state().currentJson);
state().outputJson = mvm.serializeString("out", state().currentKey, state().currentJson);
}

function disableLog() internal {
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/scripts/deploy/libs/LibMocks.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {JSON, LibJSON} from "scripts/deploy/libs/LibJSON.s.sol";
import {MockSequencerUptimeFeed} from "mocks/MockSequencerUptimeFeed.sol";
import {WETH9} from "kresko-lib/token/WETH9.sol";
import {LibSafe} from "kresko-lib/mocks/MockSafe.sol";
import {VM} from "kresko-lib/utils/LibVm.s.sol";
import {mvm} from "kresko-lib/utils/LibVm.s.sol";
import {IWETH9} from "kresko-lib/token/IWETH9.sol";
import {MockERC1155} from "mocks/MockERC1155.sol";
import {Help} from "kresko-lib/utils/Libs.s.sol";
Expand Down Expand Up @@ -51,7 +51,7 @@ library LibMocks {

if (json.params.common.sequencerUptimeFeed == address(0)) {
json.params.common.sequencerUptimeFeed = address(deploySeqFeed());
VM.warp(VM.unixTime());
mvm.warp(mvm.unixTime());
}

if (json.params.common.council == address(0)) {
Expand Down
11 changes: 0 additions & 11 deletions src/contracts/scripts/fork/Fork.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@ pragma solidity ^0.8.0;

// solhint-disable state-visibility, quotes

import {Scripted} from "kresko-lib/utils/Scripted.s.sol";
import {IWETH9} from "kresko-lib/token/IWETH9.sol";
import "scripts/deploy/JSON.s.sol" as JSON;

import {PLog} from "kresko-lib/utils/PLog.s.sol";
import {IERC20} from "kresko-lib/token/IERC20.sol";
import {IVault} from "vault/interfaces/IVault.sol";
import {Deployed} from "scripts/deploy/libs/Deployed.s.sol";
import {IGatingManager} from "periphery/IGatingManager.sol";
import {IERC1155} from "common/interfaces/IERC1155.sol";
import {IAccess} from "kresko-lib/vendor/IAccess.sol";
import {Anvil} from "scripts/utils/Utils.s.sol";
import {ArbScript} from "scripts/utils/ArbScript.s.sol";
import {Enums} from "common/Constants.sol";
import {IKrMulticall} from "periphery/IKrMulticall.sol";

contract ArbFork is ArbScript {
using Deployed for string;
Expand Down
32 changes: 3 additions & 29 deletions src/contracts/scripts/utils/ArbScript.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Scripted} from "kresko-lib/utils/Scripted.s.sol";
import {IWETH9} from "kresko-lib/token/IWETH9.sol";
import {IKresko} from "periphery/IKresko.sol";
import {Help, Log} from "kresko-lib/utils/Libs.s.sol";
import {Anvil} from "kresko-lib/utils/Anvil.s.sol";

import {IGatingManager} from "periphery/IGatingManager.sol";
import {IERC1155} from "common/interfaces/IERC1155.sol";
Expand All @@ -19,35 +20,14 @@ import {IKreskoAsset} from "kresko-asset/IKreskoAsset.sol";
import {IKreskoAssetAnchor} from "kresko-asset/IKreskoAssetAnchor.sol";
import {IERC20} from "kresko-lib/token/IERC20.sol";
import {Asset, Enums, Oracle, RawPrice} from "common/Types.sol";
import {View} from "periphery/ViewTypes.sol";
import {Anvil} from "scripts/utils/Utils.s.sol";
import {ArbDeployAddr} from "kresko-lib/info/ArbDeployAddr.sol";

// solhint-disable state-visibility, max-states-count, var-name-mixedcase, no-global-import, const-name-snakecase, no-empty-blocks, no-console

contract ArbScript is Scripted {
contract ArbScript is Scripted, ArbDeployAddr {
using Log for *;
using Help for *;

address kissAddr = 0x6A1D6D2f4aF6915e6bBa8F2db46F442d18dB5C9b;
address kreskoAddr = 0x0000000000177abD99485DCaea3eFaa91db3fe72;
address multicallAddr = 0x0000000084C577a3563a531C00c7257FF44C3052;
address factoryAddr = 0x000000000070AB95211e32fdA3B706589D3482D5;
address vaultAddr = 0x2dF01c1e472eaF880e3520C456b9078A5658b04c;

address USDCAddr = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831;
address ARBAddr = 0x912CE59144191C1204E64559FE8253a0e49E6548;
address USDCeAddr = 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8;
address WBTCAddr = 0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f;
address wethAddr = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address krETHAddr = 0x24dDC92AA342e92f26b4A676568D04d2E3Ea0abc;
address akrETHAddr = 0x3103570A28ca026e818c79608F1FF804F4Bde284;
address DAIAddr = 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1;

address stash = 0xB38e8c17e38363aF6EbdCb3dAE12e0243582891D;
address safe = 0x266489Bde85ff0dfe1ebF9f0a7e6Fed3a973cEc3;
address nftMultisig = 0x389297F0d8C489954D65e04ff0690FC54E57Dad6;
address deployer = 0x5a6B3E907b83DE2AbD9010509429683CF5ad5984;

IKresko kresko = IKresko(kreskoAddr);
IKrMulticall multicall = IKrMulticall(multicallAddr);
IVault vault = IVault(vaultAddr);
Expand All @@ -56,12 +36,6 @@ contract ArbScript is Scripted {
IKreskoAsset krETH = IKreskoAsset(krETHAddr);
IKreskoAssetAnchor akrETH = IKreskoAssetAnchor(akrETHAddr);

IWETH9 weth = IWETH9(wethAddr);
IERC20 USDC = IERC20(USDCAddr);
IERC20 USDCe = IERC20(USDCeAddr);
IERC20 WBTC = IERC20(WBTCAddr);
IERC20 ARB = IERC20(ARBAddr);

IDeploymentFactory factory = IDeploymentFactory(factoryAddr);
IDataV1 dataV1 = IDataV1(0x0D7412df8E363EA76bd29625Fb8c481bcD28611B);
IGatingManager manager = IGatingManager(0x13f14aB44B434F16D88645301515C899d69A30Bd);
Expand Down
132 changes: 0 additions & 132 deletions src/contracts/scripts/utils/Utils.s.sol

This file was deleted.

0 comments on commit 299c993

Please sign in to comment.