Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deployments/dev/534352/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"StargateModule": "0x6c906af3300294317C454A18AC552bAce9a72Fca",
"WormholeModule": "0x96F7C99AeBb38Ccc0Df091F1aD2b8f91ADBA2FCd",
"BeHYPEStakeModule": "0x89EFb0DB949f25E131239b5B41c3Ed5aFaeaaA35",
"LiquidUSDLiquifierModule": "0x1ca1349695E2584EBa01273Fd1EF9D0FffFBc852",
"EtherFiLiquidModuleWithReferrer": "0xEBC674Ec6c5968bB52Ee3F02C2a6F9Efd4ffa10d",
"LiquidUSDLiquifierModule": "0x1ca1349695E2584EBa01273Fd1EF9D0FffFBc852"
"FraxUsdModule": "0xC089660e3cdf91Dff690dA879927D5D74cAc4067"
}
}
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ base = "${BASE_RPC}"
mainnet = { key = "${ETHERSCAN_KEY}" }
scroll = { key = "${ETHERSCAN_KEY}" }
base = { key = "${ETHERSCAN_KEY}" }
hyperevm = { key = "${MAINNET_ETHERSCAN_KEY}", chain = 999 }
hyperevm = { key = "${ETHERSCAN_KEY}", chain = 999 }



Expand Down
6 changes: 6 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
forge-std/=lib/forge-std/src/
openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/
openzeppelin-contracts/=lib/openzeppelin-contracts/
solady/=lib/solady/src/
93 changes: 93 additions & 0 deletions scripts/DeployFraxModule.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { stdJson } from "forge-std/StdJson.sol";

import { EtherFiDataProvider } from "../src/data-provider/EtherFiDataProvider.sol";
import { ICashModule } from "../src/interfaces/ICashModule.sol";
import { IDebtManager } from "../src/interfaces/IDebtManager.sol";
import { FraxModule } from "../src/modules/frax/FraxModule.sol";
import { IAggregatorV3, PriceProvider } from "../src/oracle/PriceProvider.sol";
import { Utils } from "./utils/Utils.sol";

contract DeployFraxModule is Utils {
address fraxusd = 0x397F939C3b91A74C321ea7129396492bA9Cdce82;
address custodian = 0x05bF905356fbeA7E59500f904b908402dB7A53DD;
address fraxUsdPriceOracle = 0x7be4f8b373853b74CDf48FE817bC2eB2272eBe45;
address remoteHop = 0xF6f45CCB5E85D1400067ee66F9e168f83e86124E;

IDebtManager debtManager;
PriceProvider priceProvider;
ICashModule cashModule;
address dataProvider;

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(deployerPrivateKey);

string memory deployments = readDeploymentFile();
dataProvider = stdJson.readAddress(deployments, string(abi.encodePacked(".", "addresses", ".", "EtherFiDataProvider")));

priceProvider = PriceProvider(stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "PriceProvider")));

debtManager = IDebtManager(stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "DebtManager")));

cashModule = ICashModule(stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "CashModule")));

//deploy frax module
FraxModule fraxModule = new FraxModule(dataProvider, fraxusd, custodian, remoteHop);

address[] memory modules = new address[](1);
modules[0] = address(fraxModule);

bool[] memory shouldWhitelist = new bool[](1);
shouldWhitelist[0] = true;

//configure default module in data provider
EtherFiDataProvider(dataProvider).configureDefaultModules(modules, shouldWhitelist);

address[] memory tokens = new address[](1);
tokens[0] = fraxusd;

PriceProvider.Config memory fraxUsdConfig = PriceProvider.Config({
oracle: fraxUsdPriceOracle,
priceFunctionCalldata: "",
isChainlinkType: true,
oraclePriceDecimals: IAggregatorV3(fraxUsdPriceOracle).decimals(),
maxStaleness: 2 days,
dataType: PriceProvider.ReturnType.Int256,
isBaseTokenEth: false,
isStableToken: true, //Stable coin
isBaseTokenBtc: false
});
PriceProvider.Config[] memory fraxUsdConfigs = new PriceProvider.Config[](1);
fraxUsdConfigs[0] = fraxUsdConfig;

//price provider set oracle
PriceProvider(priceProvider).setTokenConfig(tokens, fraxUsdConfigs);

IDebtManager.CollateralTokenConfig memory collateralConfig = IDebtManager.CollateralTokenConfig({
ltv: 90e18, //confirmed
liquidationThreshold: 95e18,
liquidationBonus: 1e18
});

uint64 borrowApy = 1; // ~0%
uint128 minShares = type(uint128).max; // Since we dont want to use it in borrow mode

//debt manager set collateral and borrow config
debtManager.supportCollateralToken(address(fraxusd), collateralConfig);
debtManager.supportBorrowToken(address(fraxusd), borrowApy, minShares);

address[] memory withdrawableAssets = new address[](1);
withdrawableAssets[0] = address(fraxusd);

ICashModule(cashModule).configureModulesCanRequestWithdraw(modules, shouldWhitelist);

//cash module set withdrawable asset
ICashModule(cashModule).configureWithdrawAssets(withdrawableAssets, shouldWhitelist);

vm.stopBroadcast();
}
}
32 changes: 32 additions & 0 deletions scripts/gnosis-txs/DeployFraxModule.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { stdJson } from "forge-std/StdJson.sol";
import { console } from "forge-std/console.sol";

import { FraxModule } from "../../src/modules/frax/FraxModule.sol";
import { Utils } from "../utils/Utils.sol";

contract DeployFraxModule is Utils {
address fraxusd = 0x397F939C3b91A74C321ea7129396492bA9Cdce82;
address usdc = 0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4;
address custodian = 0x05bF905356fbeA7E59500f904b908402dB7A53DD;
address remoteHop = 0xF6f45CCB5E85D1400067ee66F9e168f83e86124E;

function run() public {
string memory deployments = readDeploymentFile();

address dataProvider = stdJson.readAddress(deployments, string(abi.encodePacked(".", "addresses", ".", "EtherFiDataProvider")));

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(deployerPrivateKey);

// Deploy frax module
FraxModule fraxModule = new FraxModule(dataProvider, fraxusd, custodian, remoteHop);

console.log("FraxModule deployed at:", address(fraxModule));

vm.stopBroadcast();
}
}
101 changes: 101 additions & 0 deletions scripts/gnosis-txs/SetFraxModuleConfig.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { stdJson } from "forge-std/StdJson.sol";

import { EtherFiDataProvider } from "../../src/data-provider/EtherFiDataProvider.sol";
import { ICashModule } from "../../src/interfaces/ICashModule.sol";
import { IDebtManager } from "../../src/interfaces/IDebtManager.sol";
import { IAggregatorV3, PriceProvider } from "../../src/oracle/PriceProvider.sol";
import { GnosisHelpers } from "../utils/GnosisHelpers.sol";
import { Utils } from "../utils/Utils.sol";

contract SetFraxModuleConfig is GnosisHelpers, Utils {
address cashControllerSafe = 0xA6cf33124cb342D1c604cAC87986B965F428AAC4;

address fraxusd = 0x397F939C3b91A74C321ea7129396492bA9Cdce82;
address fraxUsdPriceOracle = 0x7be4f8b373853b74CDf48FE817bC2eB2272eBe45;

function run() public {
string memory deployments = readDeploymentFile();
string memory chainId = vm.toString(block.chainid);

address fraxModule = stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "FraxModule"));

address dataProvider = stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "EtherFiDataProvider"));

address priceProvider = stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "PriceProvider"));

address debtManager = stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "DebtManager"));

address cashModule = stdJson.readAddress(deployments, string.concat(".", "addresses", ".", "CashModule"));

string memory txs = _getGnosisHeader(chainId, addressToHex(cashControllerSafe));

// Configure data provider - default modules
address[] memory modules = new address[](1);
modules[0] = fraxModule;

bool[] memory shouldWhitelist = new bool[](1);
shouldWhitelist[0] = true;

string memory configureDefaultModules = iToHex(abi.encodeWithSelector(EtherFiDataProvider.configureDefaultModules.selector, modules, shouldWhitelist));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(dataProvider), configureDefaultModules, "0", false)));

// Configure price provider
address[] memory tokens = new address[](1);
tokens[0] = fraxusd;

PriceProvider.Config memory fraxUsdConfig = PriceProvider.Config({
oracle: fraxUsdPriceOracle,
priceFunctionCalldata: "",
isChainlinkType: true,
oraclePriceDecimals: IAggregatorV3(fraxUsdPriceOracle).decimals(),
maxStaleness: 5 days, //confirmed with V & showtime
dataType: PriceProvider.ReturnType.Int256,
isBaseTokenEth: false,
isStableToken: true, // Stable coin
isBaseTokenBtc: false
});
PriceProvider.Config[] memory fraxUsdConfigs = new PriceProvider.Config[](1);
fraxUsdConfigs[0] = fraxUsdConfig;

string memory setTokenConfig = iToHex(abi.encodeWithSelector(PriceProvider.setTokenConfig.selector, tokens, fraxUsdConfigs));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(priceProvider), setTokenConfig, "0", false)));

// Configure debt manager - collateral token
IDebtManager.CollateralTokenConfig memory collateralConfig = IDebtManager.CollateralTokenConfig({
ltv: 90e18, // confirmed
liquidationThreshold: 95e18,
liquidationBonus: 1e18
});

string memory supportCollateralToken = iToHex(abi.encodeWithSelector(IDebtManager.supportCollateralToken.selector, address(fraxusd), collateralConfig));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(debtManager), supportCollateralToken, "0", false)));

// Configure debt manager - borrow token
uint64 borrowApy = 1; // ~0%
uint128 minShares = type(uint128).max; // Since we dont want to use it in borrow mode

string memory supportBorrowToken = iToHex(abi.encodeWithSelector(IDebtManager.supportBorrowToken.selector, address(fraxusd), borrowApy, minShares));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(debtManager), supportBorrowToken, "0", false)));

// Configure cash module - modules can request withdraw

string memory configureModulesCanRequestWithdraw = iToHex(abi.encodeWithSelector(ICashModule.configureModulesCanRequestWithdraw.selector, modules, shouldWhitelist));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(cashModule), configureModulesCanRequestWithdraw, "0", false)));

// Configure cash module - withdrawable assets
address[] memory withdrawableAssets = new address[](1);
withdrawableAssets[0] = address(fraxusd);

string memory configureWithdrawAssets = iToHex(abi.encodeWithSelector(ICashModule.configureWithdrawAssets.selector, withdrawableAssets, shouldWhitelist));
txs = string(abi.encodePacked(txs, _getGnosisTransaction(addressToHex(cashModule), configureWithdrawAssets, "0", true)));

vm.createDir("./output", true);
string memory path = "./output/SetFraxModuleConfig.json";
vm.writeFile(path, txs);

executeGnosisTransactionBundle(path);
}
}
9 changes: 9 additions & 0 deletions src/interfaces/IFraxCustodian.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

interface IFraxCustodian {
function deposit(uint256 amountIn, address reciever) external payable returns (uint256 shares);
function redeem(uint256 sharesIn, address reciever, address owner) external returns (uint256 amountOut);
}
12 changes: 12 additions & 0 deletions src/interfaces/IFraxRemoteHop.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}

interface IFraxRemoteHop {
function sendOFT(address _oft, uint32 _dstEid, bytes32 _to, uint256 _amountLD) external payable;
function quote(address _oft, uint32 _dstEid, bytes32 _to, uint256 _amountLD) external view returns (MessagingFee memory fee);
}
Loading