diff --git a/protocol/contracts/beanstalk/init/reseed/L2/ReseedBean.sol b/protocol/contracts/beanstalk/init/reseed/L2/ReseedBean.sol index 374fbb9fd..c29cf6762 100644 --- a/protocol/contracts/beanstalk/init/reseed/L2/ReseedBean.sol +++ b/protocol/contracts/beanstalk/init/reseed/L2/ReseedBean.sol @@ -69,51 +69,49 @@ contract ReseedBean { address internal constant AQUIFER = address(0xBA51AAAa8C2f911AE672e783707Ceb2dA6E97521); address internal constant CONSTANT_PRODUCT_2 = address(0xBA5104f2df98974A83CD10d16E24282ce6Bb647f); - // TODO: Replace with actual address. - address internal constant STABLE_2 = address(0xd771D7C0e1EBE89C9E9F663824851BB89b926d1a); - // TODO: Replace with actual address. + address internal constant STABLE_2 = address(0xBA51055Ac3068Ffd884B495BF58314493cde9653); address internal constant UPGRADEABLE_WELL_IMPLEMENTATION = - address(0x2706A171ECb68E0038378D40Dd1d136361d0cB7d); + address(0xBA510995783111be5301d93CCfD5dE4e3B28e50B); address internal constant MULTIFLOW_PUMP = address(0xBA510482E3e6B96C88A1fe34Ce58385fB554C9a9); // BEAN_ETH parameters. bytes32 internal constant BEAN_ETH_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70a730b1101631795f48768830; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70cf610e2f8ba3a784783d50c7; string internal constant BEAN_ETH_NAME = "BEAN:WETH Constant Product 2 Upgradeable Well"; string internal constant BEAN_ETH_SYMBOL = "U-BEANWETHCP2w"; address internal constant WETH = address(0x82aF49447D8a07e3bd95BD0d56f35241523fBab1); // BEAN_WSTETH parameters. bytes32 internal constant BEAN_WSTETH_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70d1f6ffabd835875bcb0f750d; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb702dd812d82cc04280f90dac20; string internal constant BEAN_WSTETH_NAME = "BEAN:WSTETH Constant Product 2 Upgradeable Well"; string internal constant BEAN_WSTETH_SYMBOL = "U-BEANWSTETHCP2w"; address internal constant WSTETH = address(0x5979D7b546E38E414F7E9822514be443A4800529); // BEAN_WEETH parameters. bytes32 internal constant BEAN_WEETH_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70282162c4d51072ae5848bcab; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb7076e0c3991a85b21f3c6d2327; string internal constant BEAN_WEETH_NAME = "BEAN:WEETH Constant Product 2 Upgradeable Well"; string internal constant BEAN_WEETH_SYMBOL = "U-BEANWEETHCCP2w"; address internal constant WEETH = address(0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe); // BEAN_WBTC parameters. bytes32 internal constant BEAN_WBTC_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70680eb1a5a9088f3a5adde7cf; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb7031803f7cfbaef420a33da4e2; string internal constant BEAN_WBTC_NAME = "BEAN:WBTC Constant Product 2 Upgradeable Well"; string internal constant BEAN_WBTC_SYMBOL = "U-BEANWBTCCP2w"; address internal constant WBTC = address(0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f); // BEAN_USDC parameters. bytes32 internal constant BEAN_USDC_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb70e8dd58a81854e1c93f594f45; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb7029aa50efeb2cc4e37ef5b62c; string internal constant BEAN_USDC_NAME = "BEAN:USDC Stable 2 Upgradeable Well"; string internal constant BEAN_USDC_SYMBOL = "U-BEANUSDCS2w"; address internal constant USDC = address(0xaf88d065e77c8cC2239327C5EDb3A432268e5831); // BEAN_USDT parameters. bytes32 internal constant BEAN_USDT_SALT = - 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb703042ef0b0e0e77d3a3e484ae; + 0xd1a0060ba708bc4bcd3da6c37efa8dedf015fb7082e11ce3f89b8cd399ffa9ee; string internal constant BEAN_USDT_NAME = "BEAN:USDT Stable 2 Upgradeable Well"; string internal constant BEAN_USDT_SYMBOL = "U-BEANUSDTS2w"; address internal constant USDT = address(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9); diff --git a/protocol/contracts/beanstalk/init/reseed/L2/ReseedWhitelist.sol b/protocol/contracts/beanstalk/init/reseed/L2/ReseedWhitelist.sol index 2b05cd92c..7f689c8cd 100644 --- a/protocol/contracts/beanstalk/init/reseed/L2/ReseedWhitelist.sol +++ b/protocol/contracts/beanstalk/init/reseed/L2/ReseedWhitelist.sol @@ -23,24 +23,27 @@ contract ReseedWhitelist { */ function init( address[] calldata tokens, + address[] calldata nonBeanTokens, AssetSettings[] calldata assets, WhitelistStatus[] calldata whitelistStatus, Implementation[] calldata oracle ) external { for (uint i; i < tokens.length; i++) { address token = tokens[i]; + address nonBeanToken = nonBeanTokens[i]; // If an LP token, initialize oracle storage variables. if (token != address(s.sys.tokens.bean) && !LibUnripe.isUnripe(token)) { s.sys.usdTokenPrice[token] = 1; s.sys.twaReserves[token].reserve0 = 1; s.sys.twaReserves[token].reserve1 = 1; } + // add asset settings for the underlying lp token s.sys.silo.assetSettings[token] = assets[i]; // add whitelist status s.sys.silo.whitelistStatuses.push(whitelistStatus[i]); // the Oracle should return the price for the non-bean asset in USD - s.sys.oracleImplementation[token] = oracle[i]; + s.sys.oracleImplementation[nonBeanToken] = oracle[i]; } } } diff --git a/protocol/contracts/ecosystem/price/BeanstalkPrice.sol b/protocol/contracts/ecosystem/price/BeanstalkPrice.sol index a2e507c08..6e3292970 100644 --- a/protocol/contracts/ecosystem/price/BeanstalkPrice.sol +++ b/protocol/contracts/ecosystem/price/BeanstalkPrice.sol @@ -18,18 +18,14 @@ contract BeanstalkPrice is WellPrice { /** * @notice Returns the non-manipulation resistant on-chain liquidiy, deltaB and price data for - * Bean in the following liquidity pools. - * - Constant Product Bean:Eth Well - * - Constant Product Bean:Wsteth Well - * NOTE: Assumes all whitelisted Wells are CP2 wells. Needs to be updated if this changes. + * Bean in all whitelisted liquidity pools. * @dev No protocol should use this function to calculate manipulation resistant Bean price data. **/ function price() external view returns (Prices memory p) { address[] memory wells = beanstalk.getWhitelistedWellLpTokens(); p.ps = new P.Pool[](wells.length); for (uint256 i = 0; i < wells.length; i++) { - // Assume all Wells are CP2 wells. - p.ps[i] = getConstantProductWell(wells[i]); + p.ps[i] = getWell(wells[i]); } // assumes that liquidity and prices on all pools uses the same precision. diff --git a/protocol/contracts/ecosystem/price/WellPrice.sol b/protocol/contracts/ecosystem/price/WellPrice.sol index d4bee4843..4bdccc61e 100644 --- a/protocol/contracts/ecosystem/price/WellPrice.sol +++ b/protocol/contracts/ecosystem/price/WellPrice.sol @@ -49,10 +49,10 @@ contract WellPrice { /** * @notice Returns the non-manipulation resistant on-chain liquidiy, deltaB and price data for - * Bean a given Well. + * Bean in a given Well. * @dev No protocol should use this function to calculate manipulation resistant Bean price data. **/ - function getConstantProductWell(address wellAddress) public view returns (P.Pool memory pool) { + function getWell(address wellAddress) public view returns (P.Pool memory pool) { IWell well = IWell(wellAddress); pool.pool = wellAddress; diff --git a/protocol/contracts/libraries/Oracle/LibUsdOracle.sol b/protocol/contracts/libraries/Oracle/LibUsdOracle.sol index 4772385e3..8802f9e5a 100644 --- a/protocol/contracts/libraries/Oracle/LibUsdOracle.sol +++ b/protocol/contracts/libraries/Oracle/LibUsdOracle.sol @@ -66,6 +66,7 @@ library LibUsdOracle { * @dev if address is 0, use the current contract. * If encodeType is 0x01, use the default chainlink implementation. * Returns 0 rather than reverting if the call fails. + * Note: token here refers to the non bean token when quoting for a well price. */ function getTokenPriceFromExternal( address token, @@ -76,7 +77,7 @@ library LibUsdOracle { Implementation memory oracleImpl = s.sys.oracleImplementation[token]; // If the encode type is type 1, use the default chainlink implementation instead. - // `target` refers to the address of the price aggergator implmenation + // `target` refers to the address of the price aggergator implmentation if (oracleImpl.encodeType == bytes1(0x01)) { // if the address in the oracle implementation is 0, use the chainlink registry to lookup address address chainlinkOraclePriceAddress = oracleImpl.target; diff --git a/protocol/foundry.toml b/protocol/foundry.toml index 5b8533466..363560bbe 100644 --- a/protocol/foundry.toml +++ b/protocol/foundry.toml @@ -45,7 +45,6 @@ ignored_warnings_from = [ gas_reports = ['*'] # Cache to `$HOME/.foundry/cache//`. no_storage_caching = false -no_match_contract = "ReseedStateTest" [profile.differential] match_test = "testDiff" diff --git a/protocol/package.json b/protocol/package.json index f08681859..5fa3625fe 100644 --- a/protocol/package.json +++ b/protocol/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@beanstalk/wells": "0.4.1", - "@beanstalk/wells1.2": "npm:@beanstalk/wells@1.2.0-prerelease3", + "@beanstalk/wells1.2": "npm:@beanstalk/wells@1.2.0", "@ethereum-waffle/chai": "4.0.10", "@nomicfoundation/hardhat-network-helpers": "^1.0.7", "@openzeppelin/contracts": "5.0.2", diff --git a/protocol/reseed/data/global.json b/protocol/reseed/data/global.json index 93ad187d7..38258c7f3 100644 --- a/protocol/reseed/data/global.json +++ b/protocol/reseed/data/global.json @@ -436,6 +436,9 @@ "0", "0", "0", + "0", + "0", + "0", "0" ], [ diff --git a/protocol/reseed/data/mocks/r9-whitelist-mock.json b/protocol/reseed/data/mocks/r9-whitelist-mock.json new file mode 100644 index 000000000..12e63e357 --- /dev/null +++ b/protocol/reseed/data/mocks/r9-whitelist-mock.json @@ -0,0 +1,83 @@ +[ + [ + "0xBEA0005B8599265D41256905A9B3073D397812E4", + "0xBEA0005B8599265D41256905A9B3073D397812E4", + [ + "0x5a049a47", + "0", + "10000", + "0", + "0", + "0x00", + "0", + "0", + "0", + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + ["0xBEA0005B8599265D41256905A9B3073D397812E4", true, false, false, false], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + [ + "0x1BEA054dddBca12889e07B3E076f511Bf1d27543", + "0x1BEA054dddBca12889e07B3E076f511Bf1d27543", + [ + "0xc8cda2a0", + "1", + "10000", + "0", + "0", + "0x00", + "0", + "0", + "0", + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + ["0x1BEA054dddBca12889e07B3E076f511Bf1d27543", true, false, false, false], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + [ + "0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788", + "0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788", + [ + "0xb0c22bb1", + "1", + "10000", + "0", + "0", + "0x00", + "0", + "0", + "0", + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + ["0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788", true, false, false, false], + ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ], + [ + "0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB", + "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + [ + "0xc84c7727", + "0", + "10000", + "0", + "0", + "0x01", + "0", + "160000000000000000000", + "16000000", + ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], + ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] + ], + ["0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB", true, true, true, true], + [ + "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612", + "0x00000000", + "0x01", + "0x000000000000000000000000000000000000000000000000000000000001fa40" + ] + ] +] \ No newline at end of file diff --git a/protocol/reseed/data/r9-whitelist.json b/protocol/reseed/data/r9-whitelist.json index f8b66e72d..6240a1f74 100644 --- a/protocol/reseed/data/r9-whitelist.json +++ b/protocol/reseed/data/r9-whitelist.json @@ -1,5 +1,6 @@ [ [ + "0xBEA0005B8599265D41256905A9B3073D397812E4", "0xBEA0005B8599265D41256905A9B3073D397812E4", [ "0x5a049a47", @@ -18,6 +19,7 @@ ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] ], [ + "0x1BEA054dddBca12889e07B3E076f511Bf1d27543", "0x1BEA054dddBca12889e07B3E076f511Bf1d27543", [ "0xc8cda2a0", @@ -36,6 +38,7 @@ ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] ], [ + "0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788", "0x1BEA059c3Ea15F6C10be1c53d70C75fD1266D788", [ "0xb0c22bb1", @@ -54,7 +57,8 @@ ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] ], [ - "0xBEA00ebA46820994d24E45dffc5c006bBE35FD89", + "0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB", + "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", [ "0xc84c7727", "0", @@ -68,11 +72,17 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA00ebA46820994d24E45dffc5c006bBE35FD89", true, true, true, true], - ["0x0000000000000000000000000000000000000000", "0x00000000", "0x00", "0x00"] + ["0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB", true, true, true, true], + [ + "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612", + "0x00000000", + "0x01", + "0x000000000000000000000000000000000000000000000000000000000001fa40" + ] ], [ - "0xBEA0039bC614D95B65AB843C4482a1A5D2214396", + "0xBEA0093f626Ce32dd6dA19617ba4e7aA0c3228e8", + "0x5979D7b546E38E414F7E9822514be443A4800529", [ "0xc84c7727", "0", @@ -86,16 +96,17 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA0039bC614D95B65AB843C4482a1A5D2214396", true, true, true, true], + ["0xBEA0093f626Ce32dd6dA19617ba4e7aA0c3228e8", true, true, true, true], [ - "0x0000000000000000000000000000000000000000", - "0x00000000", + "0x74749a1c8b2faa03c7259F90919628b1241A2ea5", + "0xb0dd7409", "0x00", "0x000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba6120000000000000000000000000000000000000000000000000000000000003840000000000000000000000000e141425bc1594b8039de6390db1cdaf4397ea22b000000000000000000000000000000000000000000000000000000000001fa4000000000000000000000000035751007a407ca6feffe80b3cb397736d2cf4dbe" ] ], [ - "0xBEA000B7fde483F4660041158D3CA53442aD393c", + "0xBEA00865405A02215B44eaADB853d0d2192Fc29D", + "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe", [ "0xc84c7727", "1", @@ -109,16 +120,17 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA000B7fde483F4660041158D3CA53442aD393c", true, true, true, true], + ["0xBEA00865405A02215B44eaADB853d0d2192Fc29D", true, true, true, true], [ - "0xb025f5907C1527F4bF2Da543f98D5C430CF32ca1", - "0x5cf4ee91", + "0x74749a1c8b2faa03c7259F90919628b1241A2ea5", + "0xb0dd7409", "0x00", "0x000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba6120000000000000000000000000000000000000000000000000000000000003840000000000000000000000000b523ae262d20a936bc152e6023996e46fdc2a95d000000000000000000000000000000000000000000000000000000000001fa400000000000000000000000005979d7b546e38e414f7e9822514be443a4800529" ] ], [ - "0xBEA0078b587E8f5a829E171be4A74B6bA1565e6A", + "0xBEA008aC57c2bEfe82E87d1D8Fb9f4784d0B73cA", + "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", [ "0xc84c7727", "1", @@ -132,11 +144,17 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA0078b587E8f5a829E171be4A74B6bA1565e6A", true, true, true, true], - ["0xd0C7101eACbB49F3deCcCc166d238410D6D46d57", "0x00000000", "0x01", "0x00"] + ["0xBEA008aC57c2bEfe82E87d1D8Fb9f4784d0B73cA", true, true, true, true], + [ + "0xd0C7101eACbB49F3deCcCc166d238410D6D46d57", + "0x00000000", + "0x01", + "0x000000000000000000000000000000000000000000000000000000000001fa40" + ] ], [ - "0xBEA00C30023E873D881da4363C00F600f5e14c12", + "0xBEA00dAf62D5549D265c5cA6D6BE87eF17881279", + "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", [ "0xc84c7727", "1", @@ -150,11 +168,17 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA00C30023E873D881da4363C00F600f5e14c12", true, true, true, true], - ["0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3", "0x00000000", "0x01", "0x00"] + ["0xBEA00dAf62D5549D265c5cA6D6BE87eF17881279", true, true, true, true], + [ + "0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3", + "0x00000000", + "0x01", + "0x000000000000000000000000000000000000000000000000000000000001fa40" + ] ], [ - "0xBEA00699562C71C2d3fFc589a848353151a71A61", + "0xBEA00bE150FEF7560A8ff3C68D07387693Ddfd0b", + "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", [ "0xc84c7727", "1", @@ -168,7 +192,12 @@ ["0x0000000000000000000000000000000000000000", "0xd8317c71", "0x00", "0x00"], ["0x0000000000000000000000000000000000000000", "0xa8b0bb83", "0x00", "0x00"] ], - ["0xBEA00699562C71C2d3fFc589a848353151a71A61", true, true, true, true], - ["0x3f3f5dF88dC9F13eac63DF89EC16ef6e7E25DdE7", "0x00000000", "0x01", "0x00"] + ["0xBEA00bE150FEF7560A8ff3C68D07387693Ddfd0b", true, true, true, true], + [ + "0x3f3f5dF88dC9F13eac63DF89EC16ef6e7E25DdE7", + "0x00000000", + "0x01", + "0x000000000000000000000000000000000000000000000000000000000001fa40" + ] ] ] diff --git a/protocol/reseed/dataConverts/convertGlobal.js b/protocol/reseed/dataConverts/convertGlobal.js index 6a3769136..7b2c98949 100644 --- a/protocol/reseed/dataConverts/convertGlobal.js +++ b/protocol/reseed/dataConverts/convertGlobal.js @@ -116,43 +116,52 @@ function parseGlobals(inputFilePath, outputFilePath) { data.rain?.roots ? convertToBigNum(data.rain.roots) : "0", Array(4).fill("0x0000000000000000000000000000000000000000000000000000000000000000") ], - // EvaluationParameters + // seedGaugeSettings [ - data.evaluationParameters?.maxBeanMaxLpGpPerBdvRatio - ? convertToBigNum(data.evaluationParameters.maxBeanMaxLpGpPerBdvRatio) + data.seedGaugeSettings?.maxBeanMaxLpGpPerBdvRatio + ? convertToBigNum(data.seedGaugeSettings.maxBeanMaxLpGpPerBdvRatio) : "0", - data.evaluationParameters?.minBeanMaxLpGpPerBdvRatio - ? convertToBigNum(data.evaluationParameters.minBeanMaxLpGpPerBdvRatio) + data.seedGaugeSettings?.minBeanMaxLpGpPerBdvRatio + ? convertToBigNum(data.seedGaugeSettings.minBeanMaxLpGpPerBdvRatio) : "0", - data.evaluationParameters?.targetSeasonsToCatchUp - ? convertToBigNum(data.evaluationParameters.targetSeasonsToCatchUp) + data.seedGaugeSettings?.targetSeasonsToCatchUp + ? convertToBigNum(data.seedGaugeSettings.targetSeasonsToCatchUp) : "0", - data.evaluationParameters?.podRateLowerBound - ? convertToBigNum(data.evaluationParameters.podRateLowerBound) + data.seedGaugeSettings?.podRateLowerBound + ? convertToBigNum(data.seedGaugeSettings.podRateLowerBound) : "0", - data.evaluationParameters?.podRateOptimal - ? convertToBigNum(data.evaluationParameters.podRateOptimal) + data.seedGaugeSettings?.podRateOptimal + ? convertToBigNum(data.seedGaugeSettings.podRateOptimal) : "0", - data.evaluationParameters?.podRateUpperBound - ? convertToBigNum(data.evaluationParameters.podRateUpperBound) + data.seedGaugeSettings?.podRateUpperBound + ? convertToBigNum(data.seedGaugeSettings.podRateUpperBound) : "0", - data.evaluationParameters?.deltaPodDemandLowerBound - ? convertToBigNum(data.evaluationParameters.deltaPodDemandLowerBound) + data.seedGaugeSettings?.deltaPodDemandLowerBound + ? convertToBigNum(data.seedGaugeSettings.deltaPodDemandLowerBound) : "0", - data.evaluationParameters?.deltaPodDemandUpperBound - ? convertToBigNum(data.evaluationParameters.deltaPodDemandUpperBound) + data.seedGaugeSettings?.deltaPodDemandUpperBound + ? convertToBigNum(data.seedGaugeSettings.deltaPodDemandUpperBound) : "0", - data.evaluationParameters?.lpToSupplyRatioUpperBound - ? convertToBigNum(data.evaluationParameters.lpToSupplyRatioUpperBound) + data.seedGaugeSettings?.lpToSupplyRatioUpperBound + ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioUpperBound) : "0", - data.evaluationParameters?.lpToSupplyRatioOptimal - ? convertToBigNum(data.evaluationParameters.lpToSupplyRatioOptimal) + data.seedGaugeSettings?.lpToSupplyRatioOptimal + ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioOptimal) : "0", - data.evaluationParameters?.lpToSupplyRatioLowerBound - ? convertToBigNum(data.evaluationParameters.lpToSupplyRatioLowerBound) + data.seedGaugeSettings?.lpToSupplyRatioLowerBound + ? convertToBigNum(data.seedGaugeSettings.lpToSupplyRatioLowerBound) : "0", - data.evaluationParameters?.excessivePriceThreshold - ? convertToBigNum(data.evaluationParameters.excessivePriceThreshold) + data.seedGaugeSettings?.excessivePriceThreshold + ? convertToBigNum(data.seedGaugeSettings.excessivePriceThreshold) + : "0", + data.seedGaugeSettings?.soilCoefficientHigh + ? convertToBigNum(data.seedGaugeSettings.soilCoefficientHigh) + : "0", + data.seedGaugeSettings?.baseReward + ? convertToBigNum(data.seedGaugeSettings.baseReward) + : "0", + data.seedGaugeSettings?.excessivePriceThreshold + ? convertToBigNum(data.seedGaugeSettings.excessivePriceThreshold) : "0" ], // ShipmentRoute diff --git a/protocol/reseed/reseed10.js b/protocol/reseed/reseed10.js index 43b193a2d..ae7811900 100644 --- a/protocol/reseed/reseed10.js +++ b/protocol/reseed/reseed10.js @@ -45,7 +45,9 @@ async function reseed10(account, L2Beanstalk, mock, verbose = true) { "LibFlood", "LibSilo", "LibPipelineConvert", - "LibUsdOracle" + "LibUsdOracle", + "LibChainlinkOracle", + "LibWell" ]; // A mapping of facet to public library names that will be linked to it. diff --git a/protocol/reseed/reseed9.js b/protocol/reseed/reseed9.js index 2c25e2af1..a5ada352c 100644 --- a/protocol/reseed/reseed9.js +++ b/protocol/reseed/reseed9.js @@ -1,19 +1,25 @@ const { upgradeWithNewFacets } = require("../scripts/diamond.js"); const { deployContract } = require("../scripts/contracts"); -const { L2_WEETH } = require("../test/hardhat/utils/constants.js"); const fs = require("fs"); -// Files -const WHITELIST_SETTINGS = "./reseed/data/r9-whitelist.json"; - -async function reseed9(account, L2Beanstalk, mock) { +async function reseed9(account, L2Beanstalk, mock = true) { console.log("-----------------------------------"); console.log("reseed9: whitelist tokens.\n"); - let assets = JSON.parse(await fs.readFileSync(WHITELIST_SETTINGS)); + + // Files + let whitelistSettingsPath; + if (true) { + whitelistSettingsPath = "./reseed/data/mocks/r9-whitelist-mock.json"; + } else { + whitelistSettingsPath = "./reseed/data/r9-whitelist.json"; + } + + let assets = JSON.parse(await fs.readFileSync(whitelistSettingsPath)); let tokens = assets.map((asset) => asset[0]); - let siloSettings = assets.map((asset) => asset[1]); - let whitelistStatuses = assets.map((asset) => asset[2]); - let oracles = assets.map((asset) => asset[3]); + let nonBeanTokens = assets.map((asset) => asset[1]); + let siloSettings = assets.map((asset) => asset[2]); + let whitelistStatuses = assets.map((asset) => asset[3]); + let oracles = assets.map((asset) => asset[4]); // deploy LSD chainlink oracle for whitelist: await deployContract("LSDChainlinkOracle", account, true, []); @@ -22,7 +28,7 @@ async function reseed9(account, L2Beanstalk, mock) { diamondAddress: L2Beanstalk, facetNames: [], initFacetName: "ReseedWhitelist", - initArgs: [tokens, siloSettings, whitelistStatuses, oracles], + initArgs: [tokens, nonBeanTokens, siloSettings, whitelistStatuses, oracles], bip: false, verbose: true, account: account diff --git a/protocol/reseed/reseedAddLiquidityAndTransfer.js b/protocol/reseed/reseedAddLiquidityAndTransfer.js index aa4db6fc4..45f289a34 100644 --- a/protocol/reseed/reseedAddLiquidityAndTransfer.js +++ b/protocol/reseed/reseedAddLiquidityAndTransfer.js @@ -3,12 +3,12 @@ const { to18, to6 } = require("../test/hardhat/utils/helpers.js"); const { impersonateToken } = require("../scripts/impersonate.js"); const WellAddresses = [ - "0xBEA00ebA46820994d24E45dffc5c006bBE35FD89", // BEAN/WETH - "0xBEA0039bC614D95B65AB843C4482a1A5D2214396", // BEAN/WstETH - "0xBEA000B7fde483F4660041158D3CA53442aD393c", // BEAN/WEETH - "0xBEA0078b587E8f5a829E171be4A74B6bA1565e6A", // BEAN/WBTC - "0xBEA00C30023E873D881da4363C00F600f5e14c12", // BEAN/USDC - "0xBEA00699562C71C2d3fFc589a848353151a71A61" // BEAN/USDT + "0xBEA00A3F7aaF99476862533Fe7DcA4b50f6158cB", // BEAN/WETH + "0xBEA0093f626Ce32dd6dA19617ba4e7aA0c3228e8", // BEAN/WstETH + "0xBEA00865405A02215B44eaADB853d0d2192Fc29D", // BEAN/WEETH + "0xBEA008aC57c2bEfe82E87d1D8Fb9f4784d0B73cA", // BEAN/WBTC + "0xBEA00dAf62D5549D265c5cA6D6BE87eF17881279", // BEAN/USDC + "0xBEA00bE150FEF7560A8ff3C68D07387693Ddfd0b" // BEAN/USDT ]; const NonBeanToken = [ @@ -43,7 +43,6 @@ async function reseedAddLiquidityAndTransfer(account, L2Beanstalk, mock = true, console.log("-----------------------------------"); console.log("add liquidity to wells and transfers to l2 beanstalk.\n"); - // todo: update bean address once finalized. await impersonateToken("0xBEA0005B8599265D41256905A9B3073D397812E4", 6); const bean = await ethers.getContractAt( "MockToken", @@ -59,15 +58,17 @@ async function reseedAddLiquidityAndTransfer(account, L2Beanstalk, mock = true, if (mock) { // mint tokens to add liquidity: await token.mint(account.address, nonBeanAmounts[i]); - await bean.mint(account.address, beanAmounts[i]); + await bean.mint(account.address, beanAmounts[i] + to6("1000000")); } await token.connect(account).approve(well.address, MAX_UINT256); await bean.connect(account).approve(well.address, MAX_UINT256); // add liquidity to well, to L2 Beanstalk: - console.log(`Adding liquidity to ${WellAddresses[i]}`); + console.log(`Adding liquidity to ${WellAddresses[i]} and performing an update to the well pump.`); await well .connect(account) .addLiquidity([beanAmounts[i], nonBeanAmounts[i]], 0, L2Beanstalk, MAX_UINT256); + // perform a 0 liq addition to update the well pumps and avoid "NotInitialized" error. + await well.connect(account).addLiquidity([0, 0], 0, L2Beanstalk, MAX_UINT256); } } diff --git a/protocol/reseed/reseedL2.js b/protocol/reseed/reseedL2.js index 365b2f516..1a440ded8 100644 --- a/protocol/reseed/reseedL2.js +++ b/protocol/reseed/reseedL2.js @@ -32,7 +32,8 @@ async function reseedL2({ start = 0, end = 11, setState = true, - deployBasin = true + deployBasin = false, + addLiquidity = true }) { if (convertData) parseBeanstalkData(); // delete prev gas report @@ -117,7 +118,7 @@ async function reseedL2({ } } // adds liquidity to wells and transfer well LP tokens to l2 beanstalk: - await reseedAddLiquidityAndTransfer(l2owner, l2BeanstalkAddress, true); + if (addLiquidity) await reseedAddLiquidityAndTransfer(l2owner, l2BeanstalkAddress, true); console.log("Reseed successful."); } diff --git a/protocol/test/foundry/Migration/ReseedState.t.sol b/protocol/test/foundry/Migration/ReseedState.t.sol index 722d8c216..bc95b7324 100644 --- a/protocol/test/foundry/Migration/ReseedState.t.sol +++ b/protocol/test/foundry/Migration/ReseedState.t.sol @@ -11,6 +11,12 @@ import {Deposit} from "contracts/beanstalk/storage/Account.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IWell} from "contracts/interfaces/basin/IWell.sol"; import "forge-std/StdUtils.sol"; +import {BeanstalkPrice, WellPrice} from "contracts/ecosystem/price/BeanstalkPrice.sol"; +import {P} from "contracts/ecosystem/price/P.sol"; + +interface IBeanstalkPrice { + function price() external view returns (P.Prices memory p); +} /** * @notice Verfifies state and functionality of the new L2 Beanstalk @@ -19,6 +25,7 @@ contract ReseedStateTest is TestHelper { // contracts for testing: address constant L2_BEANSTALK = address(0xD1A0060ba708BC4BCD3DA6C37EFa8deDF015FB70); address constant FERTILIZER = address(0xC59f881074Bf039352C227E21980317e6b969c8A); + address constant BEANSTALK_PRICE = address(0xEfE94bE746681ed73DfD15F932f9a8e8ffDdEE56); uint256 constant FIELD_ID = 0; @@ -64,9 +71,17 @@ contract ReseedStateTest is TestHelper { accountNumber = parseAccounts(numAccounts); console.log("Number of accounts: ", accountNumber); l2Beanstalk = IMockFBeanstalk(L2_BEANSTALK); + // skip(100_000_000); // l2Beanstalk.gm(address(this), 1); } + // LibUsdOracle: 0x5003dF9E48dA96e4B4390373c8ae70EbFA5415A7 + function test_beanstalkPrice() public { + // Get beanstalk price + IBeanstalkPrice beanstalkPrice = IBeanstalkPrice(BEANSTALK_PRICE); + P.Prices memory prices = beanstalkPrice.price(); + } + ////////////////// WhiteListed Tokens ////////////////// function test_whiteListedTokens() public { diff --git a/protocol/test/hardhat/beanstalkPrice.test.js b/protocol/test/hardhat/beanstalkPrice.test.js index 2274cc657..4106bc8fb 100644 --- a/protocol/test/hardhat/beanstalkPrice.test.js +++ b/protocol/test/hardhat/beanstalkPrice.test.js @@ -82,7 +82,7 @@ describe("BeanstalkPrice", function () { }); const p = await this.beanstalkPrice.price(); - const w = await this.beanstalkPrice.getConstantProductWell(this.beanEthWell.address); + const w = await this.beanstalkPrice.getWell(this.beanEthWell.address); expect(p.price).to.equal("1499997"); expect(p.liquidity).to.equal("3999994000000"); @@ -103,7 +103,7 @@ describe("BeanstalkPrice", function () { }); const p = await this.beanstalkPrice.price(); - const w = await this.beanstalkPrice.getConstantProductWell(this.beanEthWell.address); + const w = await this.beanstalkPrice.getWell(this.beanEthWell.address); expect(p.price).to.equal("749999"); expect(p.liquidity).to.equal("3999994000000"); diff --git a/yarn.lock b/yarn.lock index 300ba2338..cc6988a6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2082,7 +2082,7 @@ __metadata: resolution: "@beanstalk/protocol@workspace:protocol" dependencies: "@beanstalk/wells": "npm:0.4.1" - "@beanstalk/wells1.2": "npm:@beanstalk/wells@1.2.0-prerelease3" + "@beanstalk/wells1.2": "npm:@beanstalk/wells@1.2.0" "@ethereum-waffle/chai": "npm:4.0.10" "@nomicfoundation/hardhat-network-helpers": "npm:^1.0.10" "@nomiclabs/hardhat-ethers": "npm:^2.2.1" @@ -2245,10 +2245,10 @@ __metadata: languageName: unknown linkType: soft -"@beanstalk/wells1.2@npm:@beanstalk/wells@1.2.0-prerelease3": - version: 1.2.0-prerelease3 - resolution: "@beanstalk/wells@npm:1.2.0-prerelease3" - checksum: 10/b824397cbaa938f1526047965f921008f565bb8832011bf9768b69b378dd012529a2c621f537de84bd6a14791b8f675f388094b409185e87f010a8fc54cc06a0 +"@beanstalk/wells1.2@npm:@beanstalk/wells@1.2.0": + version: 1.2.0 + resolution: "@beanstalk/wells@npm:1.2.0" + checksum: 10/670516484f77de10e45ed30ebbbd8b076eeb70dd8a5e26950d3547bf7b2cd43713baa90fab44c7ac56d1f9e9be77d38883901d3aa1e34830eb6e1119ad3ba56f languageName: node linkType: hard