PI-8: Misc. Efficiency Improvements

Executed on April 17, 2025 at 19:23 UTC.

Summary

  1. Maximum Crop Ratio Increase: Increase the Maximum Crop Ratio from 150% to 200%.
  1. Extremely High Pod Rate Level: Introduce a new Extremely High Pod Rate level, set the threshold above which the Pod Rate is considered Extremely High to 100%, and set the Maximum Temperature adjustments for the Extremely High Pod Rate cases.
  1. Demand for Soil Measurement Update: Update the mechanism for measuring demand for Soil when Soil is sold out over the previous two Seasons.
  1. Demand for Soil Measurement Threshold: Add a minimum threshold of 25 Pinto for how much Soil must be Sown in order to measure demand for Soil.
  1. On-Chain Deposit Sorting: Add helper functions for sorting Deposits on-chain.
  1. Tractor Helper Functions: Add Tractor execution helpers, caller-context views and operator controls to support more expressive Blueprints.
  1. Interface and Event Updates: Update parameter-setting compatibility and conversion-penalty event data for integrations.

Links

Problems

1. Maximum Crop Ratio Increase

The recent increase of the Maximum Crop Ratio from 100% to 150% did not sufficiently change the ability for the protocol to incentivize Depositors to Convert LP to Pinto.

2. Extremely High Pod Rate Level

The protocol did not have a way to distinguish how it changes the Maximum Temperature when the protocol has a Pod Rate that is high but not so high that it is a potential threat to the long term health of the protocol, and when it is.

3. Demand for Soil Measurement Update

With the introduction of the Cultivation System, the protocol regularly was in the circumstance where the number of Soil issued from Season to Season was very different, such that the existing method to measure changes in demand for Soil in instances where the Soil sold out last Season no longer worked.

4. Demand for Soil Measurement Threshold

Demand for Soil was highly manipulable with very little capital due to the lack of a minimum number of Pinto that must be Sown in order to measure demand.

5. On-Chain Deposit Sorting

The inability to sort a user's Deposits on-chain led to inefficient execution when Withdrawing a user's Deposits with the lowest Mown Stalk per PDV for Tractor operations.

6. Tractor Helper Functions

Expressive Blueprints were difficult to implement given the existing set of view functions and events for Tractor metadata.

7. Interface and Event Updates

The parameter-setting interface used an older tuple signature that omitted the existing rain-related Crop Scalar setting. Conversion-penalty events reported only the Stalk lost, without identifying the account or the Grown Stalk retained.

Solutions

1. Maximum Crop Ratio Increase

Update s.sys.evaluationParameters.maxBeanMaxLpGpPerBdvRatio from 150e18 to 200e18.

2. Extremely High Pod Rate Level

Create a new Extremely High Pod Rate threshold and set it to 100%. Apply the new Extremely High Pod Rate Maximum Temperature adjustments only when the Pod Rate exceeds 100% and TWAΔP < 0.

3. Demand for Soil Measurement Update

Update the method to measure changing demand for Soil as follows.

After the 25-Pinto minimum is met, a sellout in less than 20 minutes, more than 5 minutes faster than the prior sellout, or following a Season without a sellout means increasing demand. Otherwise, sellouts within 5 minutes of the prior sellout mean increasing demand if at least 5% more Soil was Sown, and steady demand otherwise. A sellout more than 5 minutes slower uses the change in number of Soil Sown. Seasons without a sellout also use that comparison of the number of Soil Sown.

The diagram below assumes consecutive sellouts, at least 25 Pinto Sown, and a sellout time of at least 20 minutes. Its time boundaries are 5 minutes faster or slower, and its quantity boundaries are 95% and 105% of the prior Season’s Soil Sown.

If Soil did not sell out last Season but sold out the Season prior, the protocol compares the number of Soil sold across the two previous Seasons.

4. Demand for Soil Measurement Threshold

Set the minimum number of Pinto that must be Sown in a Season in order for demand for Soil to be measured – and thus not considered decreasing – to 25.

5. On-Chain Deposit Sorting

Add a function that allows anyone to validate and store a Farmer's supplied Deposit ordering for one token (depositIdList) in ascending Stem order (descending Mown Stalk per PDV) (i.e., the Deposit with the lowest Mown Stalk per PDV is at the last index in the list).

6. Tractor Helper Functions

Add external contracts to support the Tractor ecosystem. TractorHelpers provides getSortedDeposits (descending Stem) and getSortedWhitelistedTokensBySeeds (descending Seeds). Their deployment addresses are listed under Other Contract / Parameter Changes.

Egis reviewed the Sow Blueprint and supporting SiloHelpers, PriceManipulation, PerFunctionPausable and OperatorWhitelist contracts (final audit report here). The report identifies review commit c9eb6ff25dd0ae87d454ab4e5b719af3ca402f72 and resolution commit 378c67ea1dcfdd184a227c24a42dc81f8ff136cb. It does not include BeanstalkPrice or attest to the exact deployed bytecode listed here.

7. Interface and Event Updates

Update the parameter-setting interface to include the existing rain-related Crop Scalar setting. Expand conversion-penalty events to identify the account and report both Grown Stalk lost and Grown Stalk retained.

Rationale

1. Maximum Crop Ratio Increase

The protocol can incentivize LP -> Pinto Converts by awarding more Seeds to Pinto Deposits. The recent change of the Maximum Crop Ratio from 100% to 150% marked the first time the protocol was willing to offer more Seeds to Pinto Deposits than to any LP Deposit. However, this change was insufficient to incentivize enough LP -> Pinto Converts to consistently return the Pinto price to its value target. Increasing the Maximum Crop Ratio further to 200% may improve the ability of the protocol to return the Pinto price to its value target.

2. Extremely High Pod Rate Level

Before PI-8, the protocol had an Excessively High Pod Rate threshold, above which the protocol treated all Pod Rates the same. However, given the fact that the Excessively High Pod Rate threshold is still generally at a low and healthy Pod Rate, it is suboptimal for the protocol to treat all Pod Rates above that threshold identically. Introducing an Extremely High Pod Rate threshold solves this problem.

Setting the Extremely High Pod Rate threshold at 100% is a sufficiently high Pod Rate such that when the protocol has a higher Pod Rate, it should act more conservatively with respect to changes in the Maximum Temperature.

3. Demand for Soil Measurement Update

The examples below assume at least 25 Pinto were Sown and the sellout took at least 20 minutes. Similar sellout times are within 5 minutes of one another. A similar number of Soil means at least 95% but less than 105% of the prior Season’s number.

If Soil sold out in consecutive Seasons and sold out more than 5 minutes faster the second Season, demand for Soil should be considered increasing.

If Soil sold out in consecutive Seasons and at least 5% more Soil was sold the second Season, demand for Soil should be considered increasing.

If Soil sold out in consecutive Seasons and the time it took to sell out was similar and the number of Soil sold was similar, demand for Soil should be considered steady.

If Soil sold out in consecutive Seasons and the time it took to sell out was similar but the number of Soil sold out was less, demand for Soil should be considered steady because the number of Soil sold being less was a function of the protocol being willing to issue less Soil due to a significant change in TWA∆P, not there necessarily being less demand for Soil. Thus, time is a better proxy for changing demand for Soil than number of Soil sold.

If Soil sold out in consecutive Seasons and it took longer to sell out and there was a similar number of Soil sold, demand for Soil should be considered steady. This is because even though Soil took longer to sell out the second Season, if the same number of Soil was sold but Soil didn't sell out, demand for Soil would be considered steady. It would be incoherent for the protocol to consider demand for Soil to be decreasing if it sold out, but steady if it didn't sell out given the same amount of time and number of Soil sold.

If Soil sold out in consecutive Seasons and it took more than 5 minutes longer to sell out and more than 5% less Soil was sold, demand for Soil should be considered decreasing.

If Soil sold out two Seasons ago but did not sell out last Season, it makes sense for the protocol only to consider the number of Soil sown because it is possible that more Soil was sown but it didn't sell out because the increase in the Cultivation Factor resulted in a significant increase in the number of Soil available. By checking the number of Soil sown the protocol can accurately measure changing demand over the previous two Seasons.

4. Demand for Soil Measurement Threshold

The introduction of a minimum threshold below which demand for Soil is always decreasing raises the minimum number of Pinto required to influence the demand for Soil measurement. Previously, the measurement could be influenced essentially for the cost of gas. The new threshold requires at least 25 Pinto to be Sown before demand can be steady or increasing.

5. On-Chain Deposit Sorting

Pinto stores a list of Deposits that the farmer owns on chain. An on chain list allows Smart Contracts to access the value a given farmer owns, without using indexing services. The Deposit list does not enforce any sorting rules when adding/removing entries. By having an optional function that allows anyone to validate and store a supplied ordering in descending order in terms of Mown Stalk per PDV in a permissionless fashion (which in PI-8 updated the ordered array but not its index mapping), smart contracts can more easily find the Deposits with the lowest Mown Stalk per PDV in a gas efficient fashion.

TractorHelpers traverses the stored Deposit list backward in order to use the Deposits with the lowest Mown Stalk per PDV in the Sow Orderbook. This ordering depends on the stored list being sorted in ascending Stem order.

6. Tractor Helper Functions

Shared withdrawal-planning and caller-context helpers let Blueprints coordinate Deposits, operators and token transfers without duplicating that logic. Explicit execution metadata also makes Tractor activity easier for integrations to identify.

7. Interface and Event Updates

Including the existing rain-related setting in the parameter tuple keeps the administrative interface aligned with stored configuration. Identifying the account and retained Grown Stalk in conversion-penalty events gives indexers the context needed to interpret each penalty.

Contract Changes

Initialization

InitPI8.init() at 0xeb393ee29335d6f75cbadbddbd115553e275bb3c set minSoilSownDemand from 0 to 25e6 (25 Pinto per Season) and maxBeanMaxLpGpPerBdvRatio from 150e18 to 200e18 (150% to 200%). It rescaled the existing Crop Scalar to approximately preserve the Crop Ratio, then rounded the scalar down to whole percentage points.

Facet Changes

The executed diamond cut replaced 17 facets, added eight selectors and removed the prior updateSeedGaugeSettings selector. Replacing a facet does not mean every function in that facet changed.

FacetActionPrevious ImplementationNew Implementation
SiloFacetAdd / Replace0xd2d3d44edbbc66ef90b29627dfd0a06d3ca0cad40xd954a3245a868ab3e991786d4e5e71892099a19d
SiloGettersFacetAdd / Replace0xa66113be17098b2594aba1614055fcc31b3abd670x6f9a49560a1db78cd32f1332e15fcaedc77aa66b
ConvertFacetReplace0x1f421ec312c60f9f6e9f6f79e0e56f496ae27e4e0x1af9097b043e26f41d082c5adb89cd606528e526
PipelineConvertFacetReplace0x7a28dfd0e5bbf281e0a853bfeb4609ff093d0bd10xf26ab0c4a354f12c9e8fa86c423f463e2c72ddd8
TractorFacetAdd / Replace0xd06128e88b7b84c214c400b86ca17770813567cf0x007a0b3bf5a9efc922e83bf0ebe7bf27fc2103bf
FieldFacetAdd / Replace0x8906b9131b7c6354f3e14b8656b546cfcfc9edf10x0b5888a4c6fb90d26fb4d5f782d45c9e86dcc974
ApprovalFacetReplace0x65d67f299a4ad1cff49a6c77a2fb463a86643ab40x61b9a20a5fc4a9965c2309c2feff56b5ebe855cd
ConvertGettersFacetReplace0xfbad01d4c722b0850444dd63dc273ad2c1c0d3210xe0b8fca80b1a7060fea44c6f823b221ec9d7217c
GaugeFacetReplace0x55c0e1643e70f9fb7eeb8c640a303ad9de2633020x42575b2f01d18cf3ed670c9fe82ee90332739d03
GaugeGettersFacetReplace0x07d6edb2e4afad408beadaaf30bc21b8f804d1f70x0f97cb8bb44d3d7a0afaeac24bbfe152215e3c5a
SeasonFacetReplace0x5d1f0c38835a0fb55b5df11341ae217f1f8a01da0x5545a4ab5cd3f6e7db0883e73ea4805f6e1270a9
SeasonGettersFacetReplace0xab2a1bc987e64c4be13ffb090b01a5888a345c9e0xebaa2c95efc7f1cef1a57dfb5fe05f8935d7390e
TokenFacetReplace0x8ab92619de059d8777822e022baaf546a614753d0x7f492edcd56335b2d2aee29dfe39df33bbe43bb8
TokenSupportFacetReplace0xd2d6808a2b669723abc669ba5b5d79a8717344150x9d214daf535396d515d93831fc7fe5fa137b4f30
MarketplaceFacetReplace0x1fbdebc461857d5d8306a64b199ff84975dfc6f80x1f4504295c5bd57cdbd8caf4df9ab13381cb0ad4
ClaimFacetReplace0x8738f66d4a0431b084b7ff8f59097312a5b5531f0x44df048857445cd8cba3b8cc26132816d827ff14
WhitelistFacetAdd / Replace / Remove0x45ee6286468f2b1406915446913b744db5a4c5d20xaaca4a18ddad39fb3a2441ff279afde06bd61b62

Other Contract / Parameter Changes

Supporting ContractNew Deployment
BeanstalkPrice0x13D25ABCB6a19948d35654715c729c6501230b49
PriceManipulation0x774c111F471FBa61B13D63C9B585882e3c6cf7A6
OperatorWhitelist0xF4ee12763976C3025194ef0E272a8390164Cc18f
TractorHelpers0x2808b14d287F8CA77eb25B16575aF187d5A05119
SowBlueprintv00xbb0a41927895F8ca2b4ECCc659ba158735fCF28B

The table below lists the externally linked libraries recorded in the previous and new deployed facet metadata. Shared dependencies are deduplicated. LibSilo and LibTokenSilo each had two previous deployments, identified by their consuming facets. The other replaced facets had no externally linked library dependencies. Address changes do not imply that every library function changed. The final row records the additional library linked by the supporting TractorHelpers deployment.

LibraryPrevious ImplementationNew ImplementationUsed By
LibSilo0x5a686e6024d1d40994ae99979ceb63bf67724b04 (SiloFacet)
0xf5daf4e2ca77cf48f4ec17d10f0b48a8c2ca9e5c (ConvertFacet, PipelineConvertFacet, ClaimFacet)
0x49bfc93e96d467d79fc809c8f6da466f8ebb8975SiloFacet, ConvertFacet, PipelineConvertFacet, ClaimFacet
LibTokenSilo0x0da233676f46427c31928f5f85678d6737f4ec7e (SiloFacet)
0xecc6509f71b74c9b14f035d35fb9113519f88bb5 (ConvertFacet, PipelineConvertFacet, ClaimFacet)
0xe47c1d275ceb1554ce802a0755cc679294f1ae81SiloFacet, ConvertFacet, PipelineConvertFacet, ClaimFacet
LibConvert0x812d9a79aea7db58bc3b0a149ba2694ef37fd1dd0xd10b907e2f8f452c4d43848a4f632a00eff9530bConvertFacet
LibPipelineConvert0xad2f28b08ff993ee8faaeb20235234ade07730220x9b42c78bd19fdf3cf3b3c16c9184e1169bf2c7aaConvertFacet, PipelineConvertFacet
LibEvaluate0x9a2848cbde1d2fcaeebb712fd8f1eb65a4bda8740x311877f9ffbaf12b905df3e1f8c3b5f3c5527bd4SeasonFacet
LibGauge0xd749370071c7fe42bbe7b81dfa85ba8ec24864b00x28d436b9bbbe755dea4db747483f693d71847984SeasonFacet
LibIncentive0x5630463e432cbd8ddb870d646213011da91668890x09240a6c83350caaf110d9de6e23a659625d5476SeasonFacet
LibShipping0xd8a274fcabe2a5cfc1c18b1f844f7fb2941d38f50x3e3442a75ed4dd47e64e4522da625701049d6477SeasonFacet
LibWellMinting0x9500f6e8742ecb924af9c97922851d648b613d070x6dd836e7fe603bd73532bf6b5cbb188b7fcc7fa9SeasonFacet, SeasonGettersFacet
LibFlood0xc4667d3a3c7c0c42a5bf351f98861963b2597f510xff823fbb0ae114b8e41c0529c7d87702cc5d06a8SeasonFacet
LibGerminate0xc6f5423a60acd02f0c8d8d6d5281caa00899b0f90x74f0910564523a9a9a0b4db23505f653af20548cSeasonFacet
LibTractorHelpersNot applicable — new supporting dependency0xcc035410d5570f2c5e841091c87d5d051761e569TractorHelpers

Function Changes

Event Changes