Skip to content

Commit

Permalink
feat: set caps for mainnet as well
Browse files Browse the repository at this point in the history
  • Loading branch information
joshpwrk committed Oct 2, 2024
1 parent fdb0899 commit c8736fa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions scripts/deploy-perp-only-market.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ contract DeployPerpOnlyMarket is Utils {

// deploy core contracts
Market memory market = _deployMarketContracts(marketName, config, deployment);
_setCapForManager(address(deployment.srm), marketName, market);

if (!isMainnet) {
_setPermissionAndCaps(deployment, marketName, market);
_whitelistManager(address(deployment.srm));
_registerMarketToSRM(marketName, deployment, market);
}
}
// NOTE: don't forget to nominate new owner in mainnet

_writeToMarketJson(marketName, market);

Expand Down Expand Up @@ -117,11 +119,6 @@ contract DeployPerpOnlyMarket is Utils {

}

function _setPermissionAndCaps(Deployment memory deployment, string memory marketName, Market memory market) internal {
// each asset whitelist the standard manager
_whitelistAndSetCapForManager(address(deployment.srm), marketName, market);
}

function _registerMarketToSRM(string memory marketName, Deployment memory deployment, Market memory market) internal {
// find market ID
uint marketId = deployment.srm.createMarket(marketName);
Expand Down Expand Up @@ -152,10 +149,12 @@ contract DeployPerpOnlyMarket is Utils {
deployment.srm.setWhitelistedCallee(address(market.perpFeed), true);
}

function _whitelistAndSetCapForManager(address manager, string memory marketName, Market memory market) internal {
function _whitelistManager(address manager) internal {
market.perp.setWhitelistManager(manager, true);
}

(uint perpCap, , ) = Config.getSRMCaps(marketName);
functiion _setCapForManager(address manager, string memory marketName, Market memory market) internal {
(, uint perpCap, ) = Config.getSRMCaps(marketName);

market.perp.setTotalPositionCap(IManager(manager), perpCap);
}
Expand Down

0 comments on commit c8736fa

Please sign in to comment.