PI-6: Introduce Cultivation System and Crop Ratio Changes

Executed on March 12, 2025 at 22:23 UTC.

Summary

  1. Cultivation System: Introduce the Cultivation System to dynamically issue Soil in line with demand for it.
  1. Minimum Soil Issuance: Create a parameter for the minimum number of Soil that can be issued when the time-weighted average and instantaneous Pinto supply deltas are nonpositive and their minimum absolute value is nonzero and set it to 50 Soil. Each delta measures the Pinto shortage or surplus relative to the $1 peg, using time-weighted average or instantaneous pool reserves. A negative value indicates a surplus.
  1. Generalized Gauge System: Create a generalized gauge system such that any future state variable can be updated via a gauge upon the gm call with minimal development effort.
  1. Maximum Crop Ratio Increase: Increase the Maximum Crop Ratio from 100% to 150%.
  1. Crop Scalar Adjustments: Properly increase the magnitude of the Crop Scalar decreases from 1 to 2 percentage points per Season when price is Reasonably High, the Pod Rate is Reasonably or Excessively High and the L2SR is Reasonably Low as intended in PI-5 (detailed below).

Links

Problems

1. Cultivation System

When the protocol issues significant numbers of Soil that are not Sown into, it signals to the market that the protocol is not creditworthy. When the protocol issues less Soil than there is demand for, it is not borrowing efficiently. The protocol lacked a method to discover the optimal number of Soil to issue.

2. Minimum Soil Issuance

At particularly low numbers of Soil, demand for Soil cannot be accurately measured. With the introduction of the Cultivation System, which starts the number of Soil available at a very low number and then ramps it up to meet demand, the protocol may issue too little Soil to accurately measure demand.

3. Generalized Gauge System

There are potentially several state variables that could be adjusted at the beginning of each Season, but without a generalized mechanism to do so each variable required a bespoke implementation.

4. Maximum Crop Ratio Increase

The Maximum Crop Ratio of 100% limited the ability of the protocol to create a sufficiently strong incentive to counter the preference demonstrated by the market to hold Deposited LP over Deposited Pinto when it is trying to incentivize LP -> Pinto Converts.

5. Crop Scalar Adjustments

When price is Reasonably High, the Pod Rate is Reasonably or Excessively High and the L2SR is Reasonably Low, the Crop Scalar did not decrease quickly enough. PI-5 intended to increase the magnitude of the Crop Scalar adjustments in these instances, but an encoding error left the decreases at 1 percentage point per Season instead of the intended 2.

Solutions

1. Cultivation System

Introduce the Cultivation System, which uses a gauge to adjust the Cultivation Factor, which acts as a scalar on Soil issuance relative to the maximum number of Soil the protocol would be willing to issue if there was infinite demand for Soil.

The Cultivation Factor is updated as follows:

Where:

The adjustment coefficient decreases linearly from 2% to 0.5% as the Pod Rate rises from 3% to 25%, and is clamped outside those bounds. Rᴰ denotes the Pod Rate. Its lower and upper bounds are 3% and 25%, respectively.

2. Minimum Soil Issuance

The Cultivation System includes a 50-Soil floor when the time-weighted average and instantaneous Pinto supply deltas are nonpositive and their minimum absolute value is nonzero to prevent instances where the protocol issues too little Soil to be able to accurately measure demand.

Therefore, we define the Soil issued when the time-weighted average and instantaneous Pinto supply deltas are nonpositive to be:

Where:

3. Generalized Gauge System

Add the following to AppStorage:

struct GaugeData {
    GaugeId[] gaugeIds;
    mapping(GaugeId => Gauge) gauges;
}

enum GaugeId {
    CULTIVATION_FACTOR
}

Introduce a Gauge Implementation as:

struct Gauge {
    bytes value;
    address target;
    bytes4 selector;
    bytes data;
}

A gauge selector must adhere to the following function definition:

foo(
    bytes memory value,
    bytes memory systemData,
    bytes memory gaugeData
) external view returns
(
    bytes memory,
    bytes memory
)

The function must return the updated encoded value first and encoded gauge data second.

Gauges have a GaugeId that is set upon adding a new Gauge. Gauges are called during the gm call, upon which each Gauge’s returned value and/or data are stored.

The following new events are associated with the generalized gauge system:

    event Engaged(GaugeId gaugeId, bytes value);
    event AddedGauge(GaugeId gaugeId, Gauge gauge);
    event RemovedGauge(GaugeId gaugeId);
    event UpdatedGauge(GaugeId gaugeId, Gauge gauge);

4. Maximum Crop Ratio Increase

Update s.sys.evaluationParameters.maxBeanMaxLpGpPerBdvRatio from 100e18 to 150e18. These 18-decimal fixed-point values represent 100% and 150%. In the code name, Bean denotes Pinto, Bdv denotes PDV, and MaxLpGp denotes maximum LP gauge points.

5. Crop Scalar Adjustments

Update s.sys.casesV2 to reflect the Crop Scalar decreases from 1 to 2 percentage points per Season for case IDs 57–59 and 66–68. These six cases cover Reasonably High price, Reasonably Low L2SR, and Reasonably or Excessively High Pod Rate across decreasing, steady, and increasing Soil demand. Their encoded adjustment changed from −1e18 to −2e18.

PI-6 as executed. Highlighted cells show the six Crop Scalar decreases from −0.01 to −0.02. Maximum Temperature adjustments were unchanged.

Rationale

1. Cultivation System

Starting with a very low number of Soil minimizes the instances where the protocol fails to find demand for Soil by a wide margin while the protocol is raising the Maximum Temperature to discover the interest rate at which it can attract demand. Instead, the Cultivation System enables the protocol to ramp up available Soil once demand for Soil has been discovered. This should result in lower overall Maximum Temperatures necessary to reduce supply.

2. Minimum Soil Issuance

Setting a minimum Soil of 50 when the time-weighted average and instantaneous Pinto supply deltas are nonpositive and their minimum absolute value is nonzero helps ensure that the protocol can accurately measure demand for Soil even in instances where the Cultivation System would otherwise result in there being a de minimis number of Soil.

3. Generalized Gauge System

Previously, adding 1) State that updates on a gm call and 2) Logic that executes during the gm call required 1) significant technical understanding of the entire gm call, 2) an implicit understanding of the current ordering of actions within the gm, and 3) appending or manipulating the state stored on the Pinto Diamond Contract. The Generalized Gauge System introduces a framework in which new features can be appended to the gm call that 1) isolates state and logic on a Gauge basis, and 2) Introduces explicit execution ordering (i.e., the order in which the Diamond State changes within a gm call), in a modular and composable fashion, such that iterating on Gauges requires minimal onboarding and minimal background knowledge of other Gauges, in a way that minimizes additional security risk per additional Gauge.

4. Maximum Crop Ratio Increase

Prior to this change, the Maximum Crop Ratio of 100% imposed an upper bound on the ratio of Seeds per PDV of Deposited Pinto and the maximum Seeds per 1 PDV of LP Deposited of 1:1. The idea behind this limit was that at all times, the protocol should not express a preference to have Depositors hold Deposited Pinto over Deposited LP because it would mean that the protocol is not looking to preserve liquidity.

However, this failed to capture the fact that the market prefers to hold Deposited LP over Deposited Pinto, such that even if the protocol offers Deposited Pinto as many Seeds per PDV as the highest-rewarded Deposited LP token, the market may still prefer to hold LP. By setting the Maximum Crop Ratio too low, the protocol has therefore been unable to sufficiently incentivize Converts and return the price to its value target consistently when the price is too low.

5. Crop Scalar Adjustments

When price is Reasonably High, the Pod Rate is Reasonably or Excessively High and the L2SR is Reasonably Low, the Crop Scalar should decrease more quickly to more aggressively encourage Converts from Pinto to LP tokens to preserve liquidity. In similar instances but where the L2SR is Excessively Low, the protocol already acts incredibly aggressively to preserve liquidity, but in instances where the L2SR is Reasonably Low, it does not act any more aggressively than when the L2SR is Reasonably or Excessively High. This change refines the Crop Scalar change to better factor in the fact that the L2SR is lower than optimal.

Contract Changes

Initialization

Executed InitPI6.init() at 0x43474d1dabd2213ff6c18b5ba69f8c847808c2c4. It registered the Cultivation Factor gauge at 0.5, set the Soil distribution period to 86,400 seconds (24 hours) and minimum Soil issuance to 50 Soil, installed the corrected Crop Scalar cases, increased the maximum Crop Ratio from 100% to 150%, and reset the Crop Scalar to 67%.

Facet Changes

FacetActionPrevious ImplementationNew Implementation
SeasonFacetReplace0xfc52fc3c8a29f74603006ff03915770014d9f0490xa932cab249fc9ddd073cdb5d40bf304a50025cd6
SeasonGettersFacetReplace0xfa0093b9ca5d00c9e6623767eb09489d90abf1500xf3d017981d0818274210661ba3cc85d143afa78e
GaugeFacetReplace0x2a8827a73de0703b3f6e24895818a3e6d9f8eeba0x25ce5e07e26b4140086f28834dea1c092fc10f90
GaugeFacetAddN/A0x25ce5e07e26b4140086f28834dea1c092fc10f90
GaugeGettersFacetReplace0x04912d77f69bd03f8846a432b0abacfc028bea330xb1cb5aa3c2e91268aae9c97d59ad90d8df979da3
ClaimFacetReplace0x28bcfb5ad84dd460f2fd080dfd706105b8fc21c60xcbb67c0dadf1c2774215d8afd4fef34c7741474b
PipelineConvertFacetReplace0x508320dcc2b4e9f79555bcae1478e6ce736b22ab0x1c3ecf2ae6bd491d112f5a2cea5927a231437437
SiloGettersFacetReplace0x6c1dc649e93be43fff670a2407fa4edc4996bb950x48f040332c3ccccf620e3ed6bbab3d117c9238ca
OracleFacetReplace0x755b6b8844faa8361d54cdee16b418770a412cb40x72827f9a9c3f4a0e36c7de20bb7b830abf385d2e

Other Contract / Parameter Changes

Added soilDistributionPeriod = 86400 seconds and minSoilIssuance = 50e6 (50 Soil) to the evaluation parameters, replacing two reserved buffer slots. Initialized the Cultivation Factor to 50e6 (0.5), bounded by 1e6 (0.01) and 100e6 (1). Increased maxBeanMaxLpGpPerBdvRatio from 100e18 to 150e18 and reset beanToMaxLpGpPerBdvRatio to 67e18 (67%). Corrected the selected Crop Scalar decreases from 1 to 2 percentage points per Season.

The replacement facets linked the following library implementations:

All ten listed library addresses changed. ClaimFacet, PipelineConvertFacet, SiloGettersFacet, and OracleFacet retained their own source files and interfaces despite their replacement. Shared-library behavior may still change.

LibraryPrevious ImplementationNew ImplementationUsed By
LibEvaluate0x69c7d1feb4b963ff9b8338a765c13bb5c3b197920xfad4e8659830d22ce9e4d87eaef52674bf805fdbSeasonFacet
LibGauge0x07b75f35e90eb114035d3c67ac7738f11fb70a260x573c652702091e7265688902ef63c82e21917b4fSeasonFacet
LibIncentive0x4e5dae995c2e8eef23b44a95034064262326e7030x6fac8752c40475c83720acbad2f0c32476243350SeasonFacet
LibShipping0x6ccdfc6fd7885a07e5d4ee5e998a66afe6a657050xab1d90c08dfa6d4c520dad967e97c5eee1d61af2SeasonFacet
LibWellMinting0xd972df7cfd286778951aa829a40e9ab7f7db1d5a0xa31576ac3be233a845e665b98bc384b51e1f4b78SeasonFacet, SeasonGettersFacet
LibFlood0x0b316cb760a677ed1c581041c7d2118bc66aa87c0x8595c632071edec9ab2cd84350d8eef46f181577SeasonFacet
LibGerminate0x636234f909174c764d216ef9bd22175f01a107b20x30f89cd09b92938864b819a552471f2c8771c83dSeasonFacet
LibSilo0x5a686e6024d1d40994ae99979ceb63bf67724b040x85e7554e3af2cfb5ec7a90b53b15b6730055905cClaimFacet, PipelineConvertFacet
LibTokenSilo0x0da233676f46427c31928f5f85678d6737f4ec7e0x31b1b337778948f2d5a1f70722cef7cca1b72e06ClaimFacet, PipelineConvertFacet
LibPipelineConvert0xb387ad744cc1a80ab629eea5ca15459076719a7a0xc7ed19335fcfc73552394dd911cdd56db1ac5e56PipelineConvertFacet

Function Changes

  • Added cultivationFactor(bytes,bytes,bytes), a view function that returns the encoded adjusted Cultivation Factor and unchanged gauge data. It does not store the factor itself. The adjustment uses the previous Season’s recorded Soil sellout, Pod Rate, and largest-USD-liquidity Well price.

Event Changes