PI-0: Fix the PINTO:USDC Multi Flow Pump and Update Multi Flow Pump Cap Parameters
Executed on November 20, 2024 at 01:31 UTC.
Summary
- Multi Flow Pump Bug: Fix a bug in the Multi Flow Pump that caused the Pump to return incorrect data for the PINTO:USDC liquidity pool.
- Pump Parameters: Update the Wells on the Minting Whitelist to use a new Multi Flow Pump with more forgiving LP token supply and exchange rate change caps of 25% per block (2-second cap interval) in order to allow the Flood to return the price to the value target in instances of greater volatility.
- Deposit Metadata: Update the Metadata Facet to return the correct metadata.
Links
- Implementation Commit: 37de6ba04e161b2f20916d777fb49825413d83d5
Problems
1. Multi Flow Pump Bug
The implementation of the Multi Flow Pump resulted in the tryCalcLpTokenSupply helper returning MAX_UINT256_SQRT (the integer square root of uint256.max) when the Newtonian estimation in Stable2’s calcLpTokenSupply failed to converge at high prices, causing the function to revert. Using this failure value in LP token supply capping produced incorrect reserve data and excessive minting.
2. Pump Parameters
During the Flood, the Well reserves hit the LP token supply and exchange rate caps. Because it took ~2 Seasons for the Pump values to catch up to the Pinto price, the protocol would mint more than it should’ve during the Flood.
3. Deposit Metadata
The ERC-1155 Deposit token was erroneously named "Beanstalk Silo Deposits".
Solutions
1. Multi Flow Pump Bug
Upgrade the _capLpTokenSupply function in Multi Flow Pump to skip LP token supply capping if calculating the LP token supply from either the previous or current reserves fails, while continuing to apply exchange-rate capping to the current reserves.
2. Pump Parameters
Upgrade the whitelisted Wells to a new Multi Flow Pump with more forgiving LP token supply and exchange rate change caps of 25% per block (previously set to approximately 0.493862% and 0.083160%, respectively), enabling the Flood to return the Pinto price to its value target in the instance of greater upside price volatility.
3. Deposit Metadata
Update the Metadata Facet to rename the ERC-1155 Deposit token from "Beanstalk Silo Deposits" to "Pinto Silo Deposits" and update its description and trait labels to use Pinto terminology.
Rationale
1. Multi Flow Pump Bug
The Stable2 Well Function uses Newtonian estimations to perform complex calculations on-chain in an efficient fashion. The further away from the value target, the greater the chance that the Newtonian estimation fails to converge, in which case the function reverts. In the instance of a reversion, it is better for the _capLpTokenSupply function in Multi Flow Pump to skip LP token supply capping when either calculation fails because MAX_UINT256_SQRT is an extremely high value which can lead to the protocol overminting Pinto. The Pump continues using the current reserve values, subject to exchange-rate capping.
2. Pump Parameters
The initial caps were designed to mitigate inter-block MEV on Ethereum, where control of consecutive blocks can enable oracle manipulation. On Base, there is no MEV performed by the sequencer, and so the risk of setting the parameters capping changes too high is almost non-existent. The Multi Flow Pump’s initial conservative caps limited how quickly its reserve values could respond to market changes. During a Flood with significant upward price volatility, this lag reduced the effectiveness of the Flood in returning the Pinto price to its value target. The higher caps allow the Pump to respond more quickly while retaining limits on changes in LP token supply and exchange rates.
3. Deposit Metadata
The Deposit token metadata should identify Pinto so that wallets and interfaces display the correct protocol name.
Contract Changes
Initialization
InitZeroWell.init(WellData[]) was called on the following contract to upgrade the whitelisted Wells to the new Pump configuration and reset their oracle snapshots:
Facet Changes
| Facet | Action | Previous Implementation | New Implementation |
|---|---|---|---|
MetadataFacet | Replace | 0xbC9bbe5226e92970272Db91a7168786528D83f8c | 0xf6506176A027ed4d5CdBaB23d9DFcdEC2B35b2A8 |
Other Contract / Parameter Changes
New Multi Flow Pump: 0xBA51AAaA66DaB6c236B356ad713f759c206DcB93. The whitelisted Wells use this Pump with LP token supply and exchange rate change caps of 25% per 2-second cap interval (previously approximately 0.493862% and 0.083160%, respectively).
MetadataFacethas no externally linked libraries.
Function Changes
- Updated
_capLpTokenSupplyto skip LP token supply capping when either supply calculation fails, while continuing to apply exchange-rate capping to the current reserves.
- Updated
MetadataFacetmetadata returned byname()anduri(uint256)to identify Pinto, including the name, description, and trait labels.
Event Changes
- The initializer reset each upgraded Well’s oracle snapshot and emitted
WellOraclewith zerodeltaBand empty cumulative reserves.