Skip to content

Commit

Permalink
deployed latest cash contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-ef committed Oct 29, 2024
1 parent eb9a4ad commit 29a1f0d
Show file tree
Hide file tree
Showing 32 changed files with 745 additions and 824 deletions.
34 changes: 19 additions & 15 deletions deployments/534352/deployments.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{
"addresses": {
"cashDataProviderImpl": "0x26950904DCF8EcF21af72eA78D32Da830626820c",
"cashDataProviderProxy": "0x61D76fB1eb4645F30dE515d0483Bf3488F4a2B99",
"debtManagerAdminImpl": "0xe417E386Ba5C9EceD30e7A5A028Fd0FF616341fc",
"debtManagerCore": "0xA0f3A57B96Fd6CA31Fe02d45cB18c137dB1DD7b6",
"debtManagerInitializer": "0x15f3723655A1A3EC1C1c8fDd697262b82f5E8ED2",
"debtManagerProxy": "0x90da1ABeea650e420bd14bD28418bD613D1786Bb",
"etherFiCashMultisig": "0x7D829d50aAF400B8B29B3b311F4aD70aD819DC6E",
"cashDataProviderImpl": "0x3c73ac2A698F7b264A8a8b78a8022710aBB787cA",
"cashDataProviderProxy": "0x04238598eFFE31AB66F1fdeCbfBd59aa4117D69A",
"debtManagerAdminImpl": "0x0000000000000000000000000000000000000000",
"debtManagerCore": "0x0000000000000000000000000000000000000000",
"debtManagerInitializer": "0x0000000000000000000000000000000000000000",
"debtManagerProxy": "0x0000000000000000000000000000000000000000",
"etherFiWallet": "0x7D829d50aAF400B8B29B3b311F4aD70aD819DC6E",
"owner": "0x7D829d50aAF400B8B29B3b311F4aD70aD819DC6E",
"priceProvider": "0x602F0736d1DeF684fb215a6dd93c5F9085eD7E55",
"settlementDispatcherProxy": "0xC81A3cFA2CEC9B3421e13d48bB18bCE38aD1687d",
"settlementDispatcherImpl": "0x228867eB712c617b5651e70d5A6fc95B5BAD6E0A",
"priceProvider": "0x38ea1a441Ab0328b164BD1CED4e9635AbF44b890",
"recoverySigner1": "0x7fEd99d0aA90423de55e238Eb5F9416FF7Cc58eF",
"recoverySigner2": "0x24e311DA50784Cf9DB1abE59725e4A1A110220FA",
"swapper": "0xabCc719302602218172F8f3f3E9aCd69fF36344F",
"settlementDispatcherImpl": "0xa276232f6A87bFc9C657ec0A679d9218E0D552b6",
"settlementDispatcherProxy": "0x395a6F029D018F1A52E42220a293215b73914dF9",
"swapper": "0x00B09BcE1eb66f414F4C5caAffA9cc61b4f95dA4",
"usdc": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"userSafeFactory": "0xF89B1e64d72f7D083221586d17bC06c3fDa834e4",
"userSafeFactoryImpl": "0xa930e755cA1D2dD1ffDBB71eB17F127461D92F4C",
"userSafeImpl": "0xc6A9218DF914A513c5f2B21bcBe2B1C8DF4fD071",
"weETH": "0x01f0a31698C4d065659b9bdC21B3610292a1c506"
"userSafeCoreImpl": "0x07aCE651BA09318C6DfEeFc56066585780f62F18",
"userSafeEventEmitterImpl": "0xB48F11E55dC6EFF03f1e2DB5796fe118C527E67A",
"userSafeEventEmitterProxy": "0x0848D817157Bfe0e4d5625EB5E2cA0D3b83053FE",
"userSafeFactoryImpl": "0x8B4922B20bB259c3fB9273796622aa5DAfd641f6",
"userSafeFactoryProxy": "0x0c0B2Dfe0790790Af395dE23712e45e4C13fec57",
"userSafeSettersImpl": "0x83D75Ca3740Fd2d0f0Cdc9B97Ba1075aA45Adf38",
"weETH": "0x01f0a31698C4d065659b9bdC21B3610292a1c506",
"wrappedERC20Impl": "0x0000000000000000000000000000000000000000",
"wrapperTokenFactory": "0x0000000000000000000000000000000000000000"
}
}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ solc = "0.8.24"
cbor_metadata = true
ffi = true
optimizer = true
optimizer_runs = 1000
optimizer_runs = 0
evm_version = "cancun"
ast = true
build_info = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Script} from "forge-std/Script.sol";
import {SettlementDispatcher} from "../../src/settlement-dispatcher/SettlementDispatcher.sol";
import {UUPSProxy} from "../../src/UUPSProxy.sol";
import {CashDataProvider} from "../../src/utils/CashDataProvider.sol";
contract DeployCashSafe is Script {
contract DeploySettlementDispatcher is Script {
SettlementDispatcher settlementDispatcher;
// Scroll
address usdc = 0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4;
Expand Down
22 changes: 17 additions & 5 deletions script/user-safe/DeployUserSafe.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ pragma solidity ^0.8.24;

import {Utils, ChainConfig} from "./Utils.sol";
import {UserSafeFactory} from "../../src/user-safe/UserSafeFactory.sol";
import {UserSafe} from "../../src/user-safe/UserSafe.sol";
import {IUserSafe} from "../../src/interfaces/IUserSafe.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {UserSafeCore} from "../../src/user-safe/UserSafeCore.sol";

contract DeployUserSafe is Utils {
UserSafeFactory userSafeFactory;
UserSafe ownerSafe;
IUserSafe ownerSafe;
uint256 defaultDailySpendingLimit = 1000e6;
uint256 defaultMonthlySpendingLimit = 10000e6;
uint256 collateralLimit = 10000e6;
int256 timezoneOffset = 4 * 3600; // Dubai Timezone
address ownerEoa;
address recoverySigner1 = 0x7fEd99d0aA90423de55e238Eb5F9416FF7Cc58eF;
address recoverySigner2 = 0x24e311DA50784Cf9DB1abE59725e4A1A110220FA;


function run() public {
// Pulling deployer info from the environment
Expand All @@ -30,17 +34,25 @@ contract DeployUserSafe is Utils {
userSafeFactory = UserSafeFactory(
stdJson.readAddress(
deployments,
string.concat(".", "addresses", ".", "userSafeFactory")
string.concat(".", "addresses", ".", "userSafeFactoryProxy")
)
);
address cashDataProvider = stdJson.readAddress(
deployments,
string.concat(".", "addresses", ".", "cashDataProviderProxy")
);


bytes memory saltData = abi.encode("ownerSafe", block.timestamp);

ownerSafe = UserSafe(
ownerSafe = IUserSafe(
userSafeFactory.createUserSafe(
saltData,
abi.encodeWithSelector(
UserSafe.initialize.selector,
UserSafeCore.initialize.selector,
cashDataProvider,
recoverySigner1,
recoverySigner2,
abi.encode(ownerEoa),
defaultDailySpendingLimit,
defaultMonthlySpendingLimit,
Expand Down
12 changes: 10 additions & 2 deletions script/user-safe/DeployUserSafeFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ pragma solidity ^0.8.24;

import {Utils, ChainConfig} from "./Utils.sol";
import {UserSafeFactory} from "../../src/user-safe/UserSafeFactory.sol";
import {UserSafe} from "../../src/user-safe/UserSafe.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {UUPSProxy} from "../../src/UUPSProxy.sol";
import {UserSafeCore} from "../../src/user-safe/UserSafeCore.sol";
import {UserSafeSetters} from "../../src/user-safe/UserSafeSetters.sol";


contract DeployUserSafeFactory is Utils {
using stdJson for string;

UserSafeCore userSafeCoreImpl;
UserSafeSetters userSafeSettersImpl;
UserSafeFactory userSafeFactory;
address userSafeImpl;
address cashDataProvider;
Expand All @@ -36,6 +40,8 @@ contract DeployUserSafeFactory is Utils {
string.concat(".", "addresses", ".", "cashDataProviderProxy")
);

userSafeCoreImpl = new UserSafeCore();
userSafeSettersImpl = new UserSafeSetters();
address factoryImpl = address(new UserSafeFactory());

userSafeFactory = UserSafeFactory(
Expand All @@ -45,7 +51,9 @@ contract DeployUserSafeFactory is Utils {
UserSafeFactory.initialize.selector,
address(userSafeImpl),
owner,
address(cashDataProvider)
address(cashDataProvider),
address(userSafeCoreImpl),
address(userSafeSettersImpl)
))
)
);
Expand Down
36 changes: 21 additions & 15 deletions script/user-safe/MockSetup.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.24;

import {Script} from "forge-std/Script.sol";
import {UserSafeFactory} from "../../src/user-safe/UserSafeFactory.sol";
import {UserSafe, UserSafeEventEmitter} from "../../src/user-safe/UserSafe.sol";
import {MockERC20} from "../../src/mocks/MockERC20.sol";
import {MockPriceProvider} from "../../src/mocks/MockPriceProvider.sol";
import {MockSwapper} from "../../src/mocks/MockSwapper.sol";
Expand All @@ -16,14 +15,19 @@ import {Utils, ChainConfig} from "./Utils.sol";
import {MockAaveAdapter} from "../../src/mocks/MockAaveAdapter.sol";
import {UUPSProxy} from "../../src/UUPSProxy.sol";
import {CashTokenWrapperFactory, CashWrappedERC20} from "../../src/cash-wrapper-token/CashTokenWrapperFactory.sol";
import {UserSafeEventEmitter} from "../../src/user-safe/UserSafeEventEmitter.sol";
import {UserSafeCore} from "../../src/user-safe/UserSafeCore.sol";
import {UserSafeSetters} from "../../src/user-safe/UserSafeSetters.sol";
import {IUserSafe} from "../../src/interfaces/IUserSafe.sol";

contract DeployMockUserSafeSetup is Utils {
MockERC20 usdc;
MockERC20 weETH;
MockPriceProvider priceProvider;
MockSwapper swapper;
UserSafe userSafeImpl;
UserSafeEventEmitter userSafeEventEmitter;
UserSafeCore userSafeCoreImpl;
UserSafeSetters userSafeSettersImpl;
UserSafeFactory userSafeFactory;
IL2DebtManager debtManager;
CashDataProvider cashDataProvider;
Expand Down Expand Up @@ -93,12 +97,8 @@ contract DeployMockUserSafeSetup is Utils {

debtManager = IL2DebtManager(address(debtManagerProxy));

userSafeImpl = new UserSafe(
address(cashDataProvider),
recoverySigner1,
recoverySigner2
);

userSafeCoreImpl = new UserSafeCore();
userSafeSettersImpl = new UserSafeSetters();
address factoryImpl = address(new UserSafeFactory());

userSafeFactory = UserSafeFactory(
Expand All @@ -107,9 +107,10 @@ contract DeployMockUserSafeSetup is Utils {
abi.encodeWithSelector(
UserSafeFactory.initialize.selector,
delay,
address(userSafeImpl),
owner,
address(cashDataProvider)
address(cashDataProvider),
address(userSafeCoreImpl),
address(userSafeSettersImpl)
))
)
);
Expand Down Expand Up @@ -169,11 +170,6 @@ contract DeployMockUserSafeSetup is Utils {
address(priceProvider)
);
vm.serializeAddress(deployedAddresses, "swapper", address(swapper));
vm.serializeAddress(
deployedAddresses,
"userSafeImpl",
address(userSafeImpl)
);
vm.serializeAddress(
deployedAddresses,
"userSafeFactoryImpl",
Expand Down Expand Up @@ -204,6 +200,16 @@ contract DeployMockUserSafeSetup is Utils {
"userSafeFactoryProxy",
address(userSafeFactory)
);
vm.serializeAddress(
deployedAddresses,
"userSafeSettersImpl",
address(userSafeSettersImpl)
);
vm.serializeAddress(
deployedAddresses,
"userSafeCoreImpl",
address(userSafeCoreImpl)
);
vm.serializeAddress(
deployedAddresses,
"wrapperTokenFactory",
Expand Down
88 changes: 47 additions & 41 deletions script/user-safe/Setup.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.24;

import {Script} from "forge-std/Script.sol";
import {UserSafeFactory} from "../../src/user-safe/UserSafeFactory.sol";
import {UserSafe, UserSafeEventEmitter} from "../../src/user-safe/UserSafe.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {PriceProvider} from "../../src/oracle/PriceProvider.sol";
import {SwapperOpenOcean} from "../../src/utils/SwapperOpenOcean.sol";
Expand All @@ -19,14 +18,19 @@ import {CashTokenWrapperFactory, CashWrappedERC20} from "../../src/cash-wrapper-
import {IWeETH} from "../../src/interfaces/IWeETH.sol";
import {IAggregatorV3} from "../../src/interfaces/IAggregatorV3.sol";
import {SettlementDispatcher} from "../../src/settlement-dispatcher/SettlementDispatcher.sol";
import {UserSafeCore} from "../../src/user-safe/UserSafeCore.sol";
import {UserSafeSetters} from "../../src/user-safe/UserSafeSetters.sol";
import {UserSafeEventEmitter} from "../../src/user-safe/UserSafeEventEmitter.sol";
import {IUserSafe} from "../../src/interfaces/IUserSafe.sol";

contract DeployUserSafeSetup is Utils {
ERC20 usdc;
ERC20 weETH;
PriceProvider priceProvider;
SwapperOpenOcean swapper;
UserSafe userSafeImpl;
UserSafeEventEmitter userSafeEventEmitter;
UserSafeCore userSafeCoreImpl;
UserSafeSetters userSafeSettersImpl;
UserSafeFactory userSafeFactory;
IL2DebtManager debtManager;
CashDataProvider cashDataProvider;
Expand Down Expand Up @@ -140,49 +144,45 @@ contract DeployUserSafeSetup is Utils {
chainConfig.swapRouterOpenOcean,
supportedCollateralTokens
);
aaveV3Adapter = new EtherFiCashAaveV3Adapter(
chainConfig.aaveV3Pool,
chainConfig.aaveV3PoolDataProvider,
aaveV3ReferralCode,
interestRateMode
);
// aaveV3Adapter = new EtherFiCashAaveV3Adapter(
// chainConfig.aaveV3Pool,
// chainConfig.aaveV3PoolDataProvider,
// aaveV3ReferralCode,
// interestRateMode
// );

address cashWrappedERC20Impl = address(new CashWrappedERC20());
wrapperTokenFactory = new CashTokenWrapperFactory(address(cashWrappedERC20Impl), owner);
// address cashWrappedERC20Impl = address(new CashWrappedERC20());
// wrapperTokenFactory = new CashTokenWrapperFactory(address(cashWrappedERC20Impl), owner);

cashDataProviderImpl = address(new CashDataProvider());
cashDataProvider = CashDataProvider(
address(new UUPSProxy(cashDataProviderImpl, ""))
);

address[] memory collateralTokens = new address[](1);
collateralTokens[0] = address(weETH);
address[] memory borrowTokens = new address[](1);
borrowTokens[0] = address(usdc);

DebtManagerCore.CollateralTokenConfig[]
memory collateralTokenConfig = new DebtManagerCore.CollateralTokenConfig[](
1
);
// address[] memory collateralTokens = new address[](1);
// collateralTokens[0] = address(weETH);
// address[] memory borrowTokens = new address[](1);
// borrowTokens[0] = address(usdc);

collateralTokenConfig[0].ltv = ltv;
collateralTokenConfig[0].liquidationThreshold = liquidationThreshold;
collateralTokenConfig[0].liquidationBonus = liquidationBonus;
collateralTokenConfig[0].supplyCap = supplyCap;
// DebtManagerCore.CollateralTokenConfig[]
// memory collateralTokenConfig = new DebtManagerCore.CollateralTokenConfig[](
// 1
// );

debtManagerCoreImpl = address(new DebtManagerCore());
debtManagerAdminImpl = address(new DebtManagerAdmin());
debtManagerInitializer = address(new DebtManagerInitializer());
address debtManagerProxy = address(new UUPSProxy(debtManagerInitializer, ""));
// collateralTokenConfig[0].ltv = ltv;
// collateralTokenConfig[0].liquidationThreshold = liquidationThreshold;
// collateralTokenConfig[0].liquidationBonus = liquidationBonus;
// collateralTokenConfig[0].supplyCap = supplyCap;

debtManager = IL2DebtManager(address(debtManagerProxy));
// debtManagerCoreImpl = address(new DebtManagerCore());
// debtManagerAdminImpl = address(new DebtManagerAdmin());
// debtManagerInitializer = address(new DebtManagerInitializer());
// address debtManagerProxy = address(new UUPSProxy(debtManagerInitializer, ""));

userSafeImpl = new UserSafe(
address(cashDataProvider),
recoverySigner1,
recoverySigner2
);
// debtManager = IL2DebtManager(address(debtManagerProxy));

userSafeCoreImpl = new UserSafeCore();
userSafeSettersImpl = new UserSafeSetters();
factoryImpl = address(new UserSafeFactory());

userSafeFactory = UserSafeFactory(
Expand All @@ -191,9 +191,10 @@ contract DeployUserSafeSetup is Utils {
abi.encodeWithSelector(
UserSafeFactory.initialize.selector,
delay,
address(userSafeImpl),
owner,
address(cashDataProvider)
address(cashDataProvider),
address(userSafeCoreImpl),
address(userSafeSettersImpl)
))
)
);
Expand All @@ -212,7 +213,7 @@ contract DeployUserSafeSetup is Utils {
));

initializeCashDataProvider();
initializeDebtManager(debtManagerProxy, collateralTokenConfig);
// initializeDebtManager(debtManagerProxy, collateralTokenConfig);
saveDeployments();

vm.stopBroadcast();
Expand Down Expand Up @@ -274,11 +275,6 @@ contract DeployUserSafeSetup is Utils {
address(priceProvider)
);
vm.serializeAddress(deployedAddresses, "swapper", address(swapper));
vm.serializeAddress(
deployedAddresses,
"userSafeImpl",
address(userSafeImpl)
);
vm.serializeAddress(
deployedAddresses,
"userSafeFactoryImpl",
Expand All @@ -289,6 +285,16 @@ contract DeployUserSafeSetup is Utils {
"userSafeFactoryProxy",
address(userSafeFactory)
);
vm.serializeAddress(
deployedAddresses,
"userSafeCoreImpl",
address(userSafeCoreImpl)
);
vm.serializeAddress(
deployedAddresses,
"userSafeSettersImpl",
address(userSafeSettersImpl)
);
vm.serializeAddress(
deployedAddresses,
"userSafeEventEmitterImpl",
Expand Down
Loading

0 comments on commit 29a1f0d

Please sign in to comment.