diff --git a/deployments/901/AAVE.json b/deployments/901/AAVE.json new file mode 100644 index 00000000..2693e05e --- /dev/null +++ b/deployments/901/AAVE.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xF367a32a5c9855ab1184407ABEFC037d3F739EC7", + "ibpFeed": "0x500d875245dD56b8Dfbb9049e860607e4EbDBa3d", + "perp": "0x5c5413680641747Df53989F8cE4c85F79a28bcac", + "perpFeed": "0x04DAA671922Ad60EfD55BE73B180Cf62d3dc3b09", + "spotFeed": "0x19CdEC5F8154C61AD92a014b1A29D1015B1FDc6B" +} \ No newline at end of file diff --git a/deployments/901/ARB.json b/deployments/901/ARB.json new file mode 100644 index 00000000..a43efe9f --- /dev/null +++ b/deployments/901/ARB.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x3Ac61D318C992A80587B460fF84606403c57f5cb", + "ibpFeed": "0x4721Ff243322c82E635441f3Cb64d99f2FC7Ff1A", + "perp": "0xa509E4F8407189A7a9B680AbeF67AAFcbA46e6BE", + "perpFeed": "0x5174BeCA74FafFd89D6aC970Ae8D6087F3B4e5c5", + "spotFeed": "0x8cF602C87eB5a77dC2e2607fFD86325d5a6b2aD0" +} \ No newline at end of file diff --git a/deployments/901/BNB.json b/deployments/901/BNB.json new file mode 100644 index 00000000..b1deee92 --- /dev/null +++ b/deployments/901/BNB.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xAc73437CD675d68F02c0A082A50EFad12Ae45D77", + "ibpFeed": "0x7306085FB88C72ec3696160732Aae2baF7133eE2", + "perp": "0x84a60db5BCfCbC55b83b535880A07CacEF3821b0", + "perpFeed": "0x74B4598BEBEdA68F2e9F2b662995d857578F5dc6", + "spotFeed": "0x48A4f1462b407b5Be3A825b58579247334C54D56" +} \ No newline at end of file diff --git a/deployments/901/NEAR.json b/deployments/901/NEAR.json new file mode 100644 index 00000000..fb84de34 --- /dev/null +++ b/deployments/901/NEAR.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xe48256B7bC713209AEb6932F1e4B9a7b8D26B391", + "ibpFeed": "0x1178f7079c60Ea76c002dE4900b7B7Fb051731CF", + "perp": "0x59b4755aEb9aC0bF42E5964ee1C337459Fd6282A", + "perpFeed": "0xdbD92C5eB643288fe0CF22Da1851344AA8AA6714", + "spotFeed": "0xbe074E57D6a5A65791D126Ce78cb93ceDC5cc78D" +} \ No newline at end of file diff --git a/deployments/901/OP.json b/deployments/901/OP.json new file mode 100644 index 00000000..3671d3b3 --- /dev/null +++ b/deployments/901/OP.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xeBB18c10cc2cf370828F1bB8dbF12b945F8f4EdF", + "ibpFeed": "0x5178934799fCBA20fE93678692fB3f73B6DA3990", + "perp": "0x9fCA0D846588D97004A6Eeb0D03FC7540114f3C1", + "perpFeed": "0x153F80386f7B56b233dcAE3348fe30AF9E652529", + "spotFeed": "0x8B43c15406710e907fF9A57a71909a29a5EF8646" +} \ No newline at end of file diff --git a/deployments/901/PEPE.json b/deployments/901/PEPE.json new file mode 100644 index 00000000..39774f18 --- /dev/null +++ b/deployments/901/PEPE.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x12392d1b14A31e8c73DDC2910917Ce917376b7B9", + "ibpFeed": "0xf44B374AeEDeA037703CF07f0ecB853f427c535c", + "perp": "0x9a35A412EDC6BBE38A8F544Eb41f954c23430457", + "perpFeed": "0xd2eE80e6F50477B499b94300077293483948B70f", + "spotFeed": "0xD5d220Bc4A52b4f824B14359C8Fea9f1EbD5Ebe0" +} \ No newline at end of file diff --git a/deployments/901/SUI.json b/deployments/901/SUI.json new file mode 100644 index 00000000..5ea6add1 --- /dev/null +++ b/deployments/901/SUI.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x653c3b64d3F562900A86263E4cA142C1087a1E62", + "ibpFeed": "0x3B12A405040d523D0BC7f6f692976Fd75D0ecBA3", + "perp": "0xFeB5b1a4EC5D7035224a62197c67cBfF4A98180f", + "perpFeed": "0x6d6Fb61D420cF74ADD194211285b30E83532b235", + "spotFeed": "0x230cf2BeB543e5A614EA87B3e47c0aC6777Ab370" +} \ No newline at end of file diff --git a/deployments/901/TIA.json b/deployments/901/TIA.json new file mode 100644 index 00000000..0a673eaa --- /dev/null +++ b/deployments/901/TIA.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xd41A7d1a5Bc12Ef0291be572A30f8525a6926449", + "ibpFeed": "0x98D3172c4d3e6914e04586503E612303078d65Ed", + "perp": "0x4C1b50fBf5f48f166601ACFF964FE8b5C415cf53", + "perpFeed": "0x0BdBF82f1d00bb775F78Ad4bd07C3655Da5cEFD7", + "spotFeed": "0xd9226eF59F383b36E87C6311Dc545a1A38cf147a" +} \ No newline at end of file diff --git a/deployments/901/WIF.json b/deployments/901/WIF.json new file mode 100644 index 00000000..37a89358 --- /dev/null +++ b/deployments/901/WIF.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x223A31Ef4371716DCF8B3e51e4B6e85d21fb8e69", + "ibpFeed": "0xeE6b80bfA6D0fd2e559D94445170b107EF8fc4B2", + "perp": "0x7B53AE3FDd53Ad0C7c7B33Eb8E418aF2A0B4281e", + "perpFeed": "0xb06c3adAc1A583025a3Bb5C7cd2258231ec683b0", + "spotFeed": "0x4e9aBB0984FC2902096Dcc155760ec351f64A4b5" +} \ No newline at end of file diff --git a/deployments/901/WLD.json b/deployments/901/WLD.json new file mode 100644 index 00000000..2aa0ef03 --- /dev/null +++ b/deployments/901/WLD.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xcFEc9040514908f5747ea487De91058D4626eB0F", + "ibpFeed": "0x6dec8a0Aa2D3569783727E90B65b749870587F4a", + "perp": "0x50996e587524Dc6E14124B5c6BF4cF52040f6760", + "perpFeed": "0x34E2a44e7B8A6F65678b78A4D2B94a5518a6D30e", + "spotFeed": "0xd3Ab9B288B9c1Aa72D0EE790Ec656e2BbDEdF4cE" +} \ No newline at end of file diff --git a/deployments/957/AAVE.json b/deployments/957/AAVE.json new file mode 100644 index 00000000..8f66d6ca --- /dev/null +++ b/deployments/957/AAVE.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xa2199b5371Ce5F9baeB978066F9DE6CdD339a1f3", + "ibpFeed": "0xa2134E76e6ded4AF5d5aBa0802fBB241B369F4C4", + "perp": "0x4b6EbaA6cb3c6dA4Cb9b2474216794966Aba826f", + "perpFeed": "0x13Bd6B0Bc9E47f98fe1158B2f96B938521bF25e8", + "spotFeed": "0x6579C4d9AeAe2C3171C63f73B41dc9b86D02A4D0" +} \ No newline at end of file diff --git a/deployments/957/ARB.json b/deployments/957/ARB.json new file mode 100644 index 00000000..f06a95ca --- /dev/null +++ b/deployments/957/ARB.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x37065e16B49878448D1674DF471035a43f121af9", + "ibpFeed": "0xF9452690dD6FE8192Fab53F6cfa490A0D33df460", + "perp": "0xCE081Cf1ed7f41Db1822c69E9d4A2746071C8d9D", + "perpFeed": "0x2067378b579bC846E6FBB2011d41e3DD92C6ea18", + "spotFeed": "0xcB5DE1fEf7Fa2261308D9b67349BC23A4F50550c" +} \ No newline at end of file diff --git a/deployments/957/BNB.json b/deployments/957/BNB.json new file mode 100644 index 00000000..b7b94021 --- /dev/null +++ b/deployments/957/BNB.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x4D7575a523D2673B330a7E14d370E81272CD5528", + "ibpFeed": "0x3E717aEba6ad3c603bEF87DF9338880F0D1c32A3", + "perp": "0xa7C846245A24928183092231D10FCa68506629A1", + "perpFeed": "0xDF30d8f35A50b5B98580b06B9B78013Ea9B3682f", + "spotFeed": "0x0b6Cb37047599Dc39a0Ee449A054138578ACAdc6" +} \ No newline at end of file diff --git a/deployments/957/NEAR.json b/deployments/957/NEAR.json new file mode 100644 index 00000000..22359ddb --- /dev/null +++ b/deployments/957/NEAR.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xDD1B27d0892079C1eb25940d5Cb58902041BE00D", + "ibpFeed": "0xfbdcEbc6f777AE4dC789089E59ce9402a482BE22", + "perp": "0x630Fcb229f6C28c428579B39BFD40Ba793Caf009", + "perpFeed": "0x9d4004bD7a201eD0fd9BaB2e530F5C3Cf93eCd6D", + "spotFeed": "0x8b09262E3c0E7a834aCb4fcC63f151979F93F267" +} \ No newline at end of file diff --git a/deployments/957/OP.json b/deployments/957/OP.json new file mode 100644 index 00000000..c5b071a9 --- /dev/null +++ b/deployments/957/OP.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x099958Ddb5E0D957201cE2Ab386b4C364d79814B", + "ibpFeed": "0x5afaFe20c966AB2F7490dEB3B06d8eF17DFc023F", + "perp": "0x6515dfB4eaD8d3D838c342B842f098A4A5B37642", + "perpFeed": "0xeb4D1dBe594595e818001bAeD168d72dFd3366B2", + "spotFeed": "0x1cDad048e73d379023cBCDC70Cd38216d6be754d" +} \ No newline at end of file diff --git a/deployments/957/PEPE.json b/deployments/957/PEPE.json new file mode 100644 index 00000000..b5a2f71a --- /dev/null +++ b/deployments/957/PEPE.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x2411f74B78A619CD56d8982a2Df24ACad9DafF88", + "ibpFeed": "0x5E0B3b7bcDAd988839FaaBB2faD7e5C1C5e59bF2", + "perp": "0xb3573E11a3dFB6AaA6a761086943b5F1BBA311d9", + "perpFeed": "0xEE699B381fc11a39571C5e92677e8F8aA7a3FB3A", + "spotFeed": "0x4BE1814dF615FB2eeD3BDa476bD7a399b4374896" +} \ No newline at end of file diff --git a/deployments/957/SUI.json b/deployments/957/SUI.json new file mode 100644 index 00000000..718e5013 --- /dev/null +++ b/deployments/957/SUI.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0xb730fAA28A2A98a00995789874Cc0D65F34cfD1d", + "ibpFeed": "0x90312981F76Bd2D482743A1e14b2F2dBB3AA569d", + "perp": "0x63A61e914c7D2a5E0BB593De4369d004C418ECdd", + "perpFeed": "0x53c426acb8E1D1552017FD1A2c143be1C3712378", + "spotFeed": "0x52e99636fC08a9FCc240e4A6ca49AEC040066156" +} \ No newline at end of file diff --git a/deployments/957/TIA.json b/deployments/957/TIA.json new file mode 100644 index 00000000..f3335e9b --- /dev/null +++ b/deployments/957/TIA.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x4487748cBC73b9E0eD3B9fEe43a6E32372d9f617", + "ibpFeed": "0xA8677845e446CF714fa04FaA3B4e52a56f4e4912", + "perp": "0x3fD90C3d4C12190AF6C4431b87Aca06Ed5178C87", + "perpFeed": "0x5A28531a8cF3B4B65a6D9Ae4809b601615A01cE0", + "spotFeed": "0x338A67A465489A9203585D93D311dd74CFBC19FC" +} \ No newline at end of file diff --git a/deployments/957/WIF.json b/deployments/957/WIF.json new file mode 100644 index 00000000..e119c8a8 --- /dev/null +++ b/deployments/957/WIF.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x7da5dc7D2Ca6a85FB17b02776c948056cB8F61A5", + "ibpFeed": "0xd3dF6B593E4663309c1fE8E490Ccf12B713286af", + "perp": "0x84715f8BD3A0bab44aD357288ABD233cC833e3F0", + "perpFeed": "0xE575Fce5138ECC85B706B061eF227B8d47CefAF9", + "spotFeed": "0xD4160017e17334187386932e5Dd9B8962EB47D25" +} \ No newline at end of file diff --git a/deployments/957/WLD.json b/deployments/957/WLD.json new file mode 100644 index 00000000..6fa72045 --- /dev/null +++ b/deployments/957/WLD.json @@ -0,0 +1,7 @@ +{ + "iapFeed": "0x2d69295A27679895f2b85f9582992C4860bFfe33", + "ibpFeed": "0x712Dcd7607FAB5a05c5c4D3cA6CD193d33109e8e", + "perp": "0xae6b2ACb22053E3541DE86a4c0420e5063655AFB", + "perpFeed": "0x39C2709b508cF4839340aC479c8FB0B8cEe01569", + "spotFeed": "0x63668B482722ee22e61F5a98A320e7Dd2852c7F4" +} \ No newline at end of file diff --git a/lib/chainlink b/lib/chainlink index 5c0ac387..99d9d28d 160000 --- a/lib/chainlink +++ b/lib/chainlink @@ -1 +1 @@ -Subproject commit 5c0ac3879bef46b828d460960702c1587f730909 +Subproject commit 99d9d28dd21cf4a6c851a1a86b5116878c651d74 diff --git a/scripts/config-mainnet.sol b/scripts/config-mainnet.sol index b85d49df..0ccb49b6 100644 --- a/scripts/config-mainnet.sol +++ b/scripts/config-mainnet.sol @@ -191,16 +191,6 @@ library Config { unpairedMMScale: 1.3e18, mmOffsetScale: 1.05e18 }); - } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SOL"))) { - perpMarginRequirements = IStandardManager.PerpMarginRequirements({ - mmPerpReq: 0.1e18, - imPerpReq: 0.2e18 - }); - } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("DOGE"))) { - perpMarginRequirements = IStandardManager.PerpMarginRequirements({ - mmPerpReq: 0.1e18, - imPerpReq: 0.2e18 - }); } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("rswETH"))) { baseMarginParams = IStandardManager.BaseMarginParams({ marginFactor: 0.65e18, @@ -248,8 +238,68 @@ library Config { }); } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("eBTC"))) { baseMarginParams = IStandardManager.BaseMarginParams({ - marginFactor: 0.65e18, - IMScale: 0.77e18 + marginFactor: 0.9e18, + IMScale: 0.945e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SOL"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("DOGE"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("TIA"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SUI"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("NEAR"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("PEPE"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.143e18, + imPerpReq: 0.2e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("WIF"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.143e18, + imPerpReq: 0.2e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("WLD"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("BNB"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("AAVE"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("OP"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 + }); + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("ARB"))) { + perpMarginRequirements = IStandardManager.PerpMarginRequirements({ + mmPerpReq: 0.067e18, + imPerpReq: 0.1e18 }); } else { revert("market not supported"); @@ -281,14 +331,6 @@ library Config { perpCap = 0; optionCap = 30_000e18; baseCap = 30_000e18; - } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SOL"))) { - perpCap = 1_000_000e18; - optionCap = 0; - baseCap = 0; - } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("DOGE"))) { - perpCap = 10_000_000e18; - optionCap = 0; - baseCap = 0; } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("rswETH"))) { perpCap = 0; optionCap = 0; @@ -329,6 +371,54 @@ library Config { perpCap = 0; optionCap = 0; baseCap = 10_000_000e18; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SOL"))) { + perpCap = 1_000_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("DOGE"))) { + perpCap = 10_000_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("TIA"))) { + perpCap = 200_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("SUI"))) { + perpCap = 500_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("NEAR"))) { + perpCap = 80_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("PEPE"))) { + perpCap = 40_000_000_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("WIF"))) { + perpCap = 200_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("WLD"))) { + perpCap = 200_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("BNB"))) { + perpCap = 1_600e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("AAVE"))) { + perpCap = 6_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("OP"))) { + perpCap = 500_000e18; + optionCap = 0; + baseCap = 0; + } else if (keccak256(abi.encodePacked(market)) == keccak256(abi.encodePacked("ARB"))) { + perpCap = 1_500_000e18; + optionCap = 0; + baseCap = 0; } else { revert("market not supported"); } diff --git a/scripts/deploy-perp-only-market.s.sol b/scripts/deploy-perp-only-market.s.sol index 40c2c4fa..357b83a9 100644 --- a/scripts/deploy-perp-only-market.s.sol +++ b/scripts/deploy-perp-only-market.s.sol @@ -8,6 +8,7 @@ import {LyraSpotFeed} from "../src/feeds/LyraSpotFeed.sol"; import {PerpAsset} from "../src/assets/PerpAsset.sol"; import {LyraSpotDiffFeed} from "../src/feeds/LyraSpotDiffFeed.sol"; import {BasePortfolioViewer} from "../src/risk-managers/BasePortfolioViewer.sol"; +import {PMRM} from "../src/risk-managers/PMRM.sol"; import {IManager} from "../src/interfaces/IManager.sol"; import {IVolFeed} from "../src/interfaces/IVolFeed.sol"; import {IForwardFeed} from "../src/interfaces/IForwardFeed.sol"; @@ -21,8 +22,18 @@ import "./config-mainnet.sol"; /** - * MARKET_NAME=weth forge script scripts/deploy-market.s.sol --private-key {} --rpc {} --broadcast + * MARKET_NAME=AAVE PRIVATE_KEY={} MAINNET_OWNER={} forge script scripts/deploy-perp-only-market.s.sol --private-key {} --rpc-url {} --verify --verifier blockscout --verifier-url {} --broadcast --priority-gas-price 1 **/ + +// MAINNET +// RPC: https://rpc.lyra.finance +// VERIFIER: https://explorer.derive.xyz/api + +// TESTNET +// RPC: https://rpc-prod-testnet-0eakp60405.t.conduit.xyz +// VERIFIER: https://explorer-prod-testnet-0eakp60405.t.conduit.xyz/api + +// will need to use an API key endpoint as limits will get hit contract DeployPerpOnlyMarket is Utils { /// @dev main function @@ -44,11 +55,26 @@ contract DeployPerpOnlyMarket is Utils { Deployment memory deployment = _loadDeployment(); // deploy core contracts - Market memory market = _deployMarketContracts(marketName, config, deployment); + Market memory market = _deployMarketContracts(config, deployment); + _setCapForManager(address(deployment.srm), marketName, market); + _whitelistManager(address(deployment.srm), market); - _setPermissionAndCaps(deployment, marketName, market); + if (block.chainid != 957) { + _registerMarketToSRM(marketName, deployment, market); - _registerMarketToSRM(marketName, deployment, market); + PMRM(_getContract("ETH", "pmrm")).setWhitelistedCallee(address(market.spotFeed), true); + PMRM(_getContract("ETH", "pmrm")).setWhitelistedCallee(address(market.iapFeed), true); + PMRM(_getContract("ETH", "pmrm")).setWhitelistedCallee(address(market.ibpFeed), true); + PMRM(_getContract("ETH", "pmrm")).setWhitelistedCallee(address(market.perpFeed), true); + + PMRM(_getContract("BTC", "pmrm")).setWhitelistedCallee(address(market.spotFeed), true); + PMRM(_getContract("BTC", "pmrm")).setWhitelistedCallee(address(market.iapFeed), true); + PMRM(_getContract("BTC", "pmrm")).setWhitelistedCallee(address(market.ibpFeed), true); + PMRM(_getContract("BTC", "pmrm")).setWhitelistedCallee(address(market.perpFeed), true); + + } else { + _transferOwner(market, vm.envAddress("MAINNET_OWNER")); + } _writeToMarketJson(marketName, market); @@ -57,7 +83,7 @@ contract DeployPerpOnlyMarket is Utils { /// @dev deploy all contract needed for a single market - function _deployMarketContracts(string memory marketName, ConfigJson memory config, Deployment memory deployment) internal returns (Market memory market) { + function _deployMarketContracts(ConfigJson memory config, Deployment memory deployment) internal returns (Market memory market) { market.spotFeed = new LyraSpotFeed(); // feeds for perp @@ -83,10 +109,10 @@ contract DeployPerpOnlyMarket is Utils { market.ibpFeed.addSigner(config.feedSigners[i], true); } - market.spotFeed.setRequiredSigners(config.feedSigners.length); - market.perpFeed.setRequiredSigners(config.feedSigners.length); - market.iapFeed.setRequiredSigners(config.feedSigners.length); - market.ibpFeed.setRequiredSigners(config.feedSigners.length); + market.spotFeed.setRequiredSigners(uint8(config.feedSigners.length)); + market.perpFeed.setRequiredSigners(uint8(config.feedSigners.length)); + market.iapFeed.setRequiredSigners(uint8(config.feedSigners.length)); + market.ibpFeed.setRequiredSigners(uint8(config.feedSigners.length)); // Deploy and configure perp (int staticInterestRate, int fundingRateCap, uint fundingConvergencePeriod) = Config.getPerpParams(); @@ -105,11 +131,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); @@ -140,14 +161,26 @@ 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, Market memory market) internal { market.perp.setWhitelistManager(manager, true); + } - (uint perpCap, , ) = Config.getSRMCaps(marketName); + function _setCapForManager(address manager, string memory marketName, Market memory market) internal { + (uint perpCap,, ) = Config.getSRMCaps(marketName); market.perp.setTotalPositionCap(IManager(manager), perpCap); } + function _transferOwner(Market memory market, address newOwner) internal { + market.perp.transferOwnership(newOwner); + market.spotFeed.transferOwnership(newOwner); + market.iapFeed.transferOwnership(newOwner); + market.ibpFeed.transferOwnership(newOwner); + market.perpFeed.transferOwnership(newOwner); + + console2.log("New owner for market: ", newOwner); + } + /** * @dev write to deployments/{network}/{marketName}.json */ diff --git a/scripts/settle-options.s.sol b/scripts/settle-options.s.sol new file mode 100644 index 00000000..28579c9a --- /dev/null +++ b/scripts/settle-options.s.sol @@ -0,0 +1,69 @@ +pragma solidity ^0.8.0; + +import "../src/assets/CashAsset.sol"; +import "../src/assets/InterestRateModel.sol"; +import "../src/liquidation/DutchAuction.sol"; +import "../src/SubAccounts.sol"; +import "../src/SecurityModule.sol"; +import "../src/risk-managers/StandardManager.sol"; +import "../src/risk-managers/SRMPortfolioViewer.sol"; +import "../src/periphery/OracleDataSubmitter.sol"; + +import "../src/feeds/LyraSpotFeed.sol"; + +import "openzeppelin/token/ERC20/extensions/IERC20Metadata.sol"; + +import "forge-std/console2.sol"; +import {Deployment, ConfigJson} from "./types.sol"; +import {Utils} from "./utils.sol"; + +// Read from deployment config +import "./config-mainnet.sol"; +import "../src/periphery/PerpSettlementHelper.sol"; +import "../src/periphery/OptionSettlementHelper.sol"; +import {IOptionAsset} from "../src/interfaces/IOptionAsset.sol"; +import {ILiquidatableManager} from "../src/interfaces/ILiquidatableManager.sol"; + +// Or just call one by one +// cast send {ManagerContract} "settleOptions(address,uint256)" {OptionAsset} {SubaccountId} --rpc-url https://rpc-prod-testnet-0eakp60405.t.conduit.xyz --private-key <...> --priority-gas-price 1 + +/* + * PRIVATE_KEY=<...> forge script scripts/settle-options.s.sol --private-key <...> --rpc-url https://rpc-prod-testnet-0eakp60405.t.conduit.xyz --broadcast --priority-gas-price 1 + */ +contract DeployCore is Utils { + /// @dev main function + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + vm.startBroadcast(deployerPrivateKey); + + address deployer = vm.addr(deployerPrivateKey); + console2.log("Start deploying core contracts! deployer: ", deployer); + + // STEP 1: define subaccount to settle (find them in admin dashboard / balances) + // STEP 2: make sure thesea are only SRM or PMRM + uint256[3] memory subaccountsToSettle = [ + uint256(47288), + uint256(50310), + uint256(77556) + ]; + + for (uint i = 0; i < subaccountsToSettle.length; i++) { + console2.log("Settling subaccount: ", subaccountsToSettle[i]); + + // STEP 3: set PMRM or SRM as manager to call + // ILiquidatableManager( + // address(0x28bE681F7bEa6f465cbcA1D25A2125fe7533391C) // [TESTNET] SRM + ILiquidatableManager( + address(0xDF448056d7bf3f9Ca13d713114e17f1B7470DeBF) // [TESTNET] PMRM ETH + ).settleOptions( + // STEP 4: choose ETH vs BTC option asset + IOptionAsset( + address(0xBcB494059969DAaB460E0B5d4f5c2366aab79aa1) + ), + subaccountsToSettle[i] + ); + } + + vm.stopBroadcast(); + } +}