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
58 changes: 58 additions & 0 deletions script/deploy_marketFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
pragma solidity 0.8.34;

import "forge-std/Script.sol";

import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

import { MarketFactory } from "../src/moolah/MarketFactory.sol";

contract MarketFactoryDeploy is Script {
address moolah = 0x8F73b65B4caAf64FBA2aF91cC5D4a2A1318E5D8C;
address liquidator = 0x6a87C15598929B2db22cF68a9a0dDE5Bf297a59a;
address publicLiquidator = 0x882475d622c687b079f149B69a15683FCbeCC6D9;
address listaRevenueDistributor = 0x34B504A5CF0fF41F8A480580533b6Dda687fa3Da;
address buyback = 0x3b99A4177E3f430590A8473f353dD87a5a2e1BfC;
address autoBuyback = 0xFfd3a57E8DB4f51FA01c72F06Ff30BDFDa9908e6;
address WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
address slisBNB = 0xB0b84D294e0C75A6abe60171b70edEb2EFd14A1B;
address BNBProvider = 0x367384C54756a25340c63057D87eA22d47Fd5701;
address slisBNBProvider = 0x33f7A980a246f9B8FEA2254E3065576E127D4D5f;
address rateCalculator = 0xF81A3067ACF683B7f2f40a22bCF17c8310be2330;
address brokerLiquidator = 0x3AA647a1e902833b61E503DbBFbc58992daa4868;

address operator = 0x8d388136d578dCD791D081c6042284CED6d9B0c6;
address pauser = 0xEEfebb1546d88EA0909435DF6f615084DD3c5Bd8;

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
console.log("Deployer: ", deployer);
vm.startBroadcast(deployerPrivateKey);

// Deploy implementation
MarketFactory impl = new MarketFactory(
moolah,
liquidator,
publicLiquidator,
listaRevenueDistributor,
buyback,
autoBuyback,
WBNB,
slisBNB,
BNBProvider,
slisBNBProvider,
rateCalculator,
brokerLiquidator
);
console.log("Implementation: ", address(impl));

// Deploy proxy
ERC1967Proxy proxy = new ERC1967Proxy(
address(impl),
abi.encodeWithSelector(impl.initialize.selector, deployer, operator, pauser)
);
console.log("Loop WBNB Vault BNBProvider proxy: ", address(proxy));

vm.stopBroadcast();
}
}
27 changes: 27 additions & 0 deletions script/deploy_marketFactoryTransferRole.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pragma solidity 0.8.34;

import "forge-std/Script.sol";

import { MarketFactory } from "../src/moolah/MarketFactory.sol";

contract MarketFactoryTransferRoleDeploy is Script {
MarketFactory marketFactory = MarketFactory(0x8F73b65B4caAf64FBA2aF91cC5D4a2A1318E5D8C);
address admin = 0x07D274a68393E8b8a2CCf19A2ce4Ba3518735253;

bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
console.log("Deployer: ", deployer);
vm.startBroadcast(deployerPrivateKey);

// setup roles
marketFactory.grantRole(DEFAULT_ADMIN_ROLE, admin);
marketFactory.revokeRole(DEFAULT_ADMIN_ROLE, deployer);

vm.stopBroadcast();

console.log("setup role done!");
}
}
9 changes: 9 additions & 0 deletions src/broker/interfaces/IBroker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,13 @@ interface IBroker is IBrokerBase {
/// @dev get the total debt of a user including principal and interest
/// @param user The address of the user
function getUserTotalDebt(address user) external view returns (uint256 totalDebt);

/// @dev set the market id for the broker, callable by owner only
/// @param marketId The market id to set
function setMarketId(Id marketId) external;

/// @dev toggle the liquidation whitelist status of an account
/// @param account The address of the account
/// @param isAddition Whether to add or remove the account from the whitelist
function toggleLiquidationWhitelist(address account, bool isAddition) external;
}
2 changes: 2 additions & 0 deletions src/broker/interfaces/IRateCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface IRateCalculator {
*/
function getRate(address broker) external view returns (uint256);

function registerBroker(address _broker, uint256 _ratePerSecond, uint256 _maxRatePerSecond) external;

/// ------------------------------
/// Events
/// ------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/liquidator/IBrokerLiquidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ interface IBrokerLiquidator {
function marketIdToBroker(bytes32 id) external view returns (address);

function brokerToMarketId(address broker) external view returns (bytes32);

function tokenWhitelist(address token) external view returns (bool);
}
6 changes: 6 additions & 0 deletions src/liquidator/ILiquidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ interface ILiquidator {
function setPairWhitelist(address pair, bool status) external;

function marketWhitelist(bytes32 id) external view returns (bool);

function tokenWhitelist(address token) external view returns (bool);

function batchSetSmartProviders(address[] calldata smartProviders, bool status) external;

function smartProviders(address provider) external view returns (bool);
}
4 changes: 4 additions & 0 deletions src/liquidator/IPublicLiquidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ interface IPublicLiquidator {
function setMarketUserWhitelist(bytes32 id, address user, bool status) external;

function setPairWhitelist(address pair, bool status) external;

function batchSetSmartProviders(address[] calldata providers, bool status) external;

function smartProviders(address provider) external view returns (bool);
}
Loading
Loading