PI-9: Helper Function Bug Fix

Executed on April 18, 2025 at 18:48 UTC.

Summary

Update the _setSortedDepositIds function to properly set the Deposit ID-to-index mapping.

Links

Problem

The protocol stores a list of each Farmer's Deposits on-chain, which is used to allow clients like the Pinto UI to easily query Deposit data. The protocol also stores a mapping of Deposit IDs to index in order to efficiently look up a Deposit's index. PI-8 introduced an updateSortedDepositIds function that allows anyone to submit a Deposit ordering for one token, validated in ascending Stem order, but this function did not properly update the mapping to reflect the new ordering. As a result, a later full Deposit removal could use a stale index and remove the wrong ID from the list.

Solution

Update LibSilo._setSortedDepositIds to properly update the mapping based on the new ordering. Each Deposit ID is mapped to its zero-based index before the ordered list is stored.

Rationale

Keeping the index mapping consistent with the ordered list preserves correct Deposit index lookup and removal after reordering. The existing validation requires a nonempty, complete list in strictly ascending Stem order.

Contract Changes

Initialization

No initializer was called. The upgrade did not automatically rewrite existing account mappings. A successful call to updateSortedDepositIds updates the supplied account and token’s index mapping.

Facet Changes

FacetActionPrevious ImplementationNew Implementation
ApprovalFacetReplace0x61b9a20a5fc4a9965c2309c2feff56b5ebe855cd0xa7c95ed70be8f91f8d8af91de193710fa7ab32bb
ClaimFacetReplace0x44df048857445cd8cba3b8cc26132816d827ff140xd38c3e61bf08734cd808aca15c944389968612e0
ConvertFacetReplace0x1af9097b043e26f41d082c5adb89cd606528e5260xdfa197784879926e2358a7c71c6a0bd487f919fd
PipelineConvertFacetReplace0xf26ab0c4a354f12c9e8fa86c423f463e2c72ddd80xc54cd71bfa5d0fe05d887eabbec4dbbc94cf74ba
SiloFacetReplace0xd954a3245a868ab3e991786d4e5e71892099a19d0xf6af001b8879a2e30db294b4c8deccbd0d168b34
SiloGettersFacetReplace0x6f9a49560a1db78cd32f1332e15fcaedc77aa66b0xadfd7fbe59ca2624cec1b04f9bc65c7f90efed36

All six facets were replaced with unchanged external interfaces. The changed internal helper is called only by SiloFacet.updateSortedDepositIds(). The other replacements do not introduce additional function changes.

Other Contract / Parameter Changes

The externally linked libraries below were redeployed. Only LibSilo’s own source changed. LibTokenSilo, LibConvert and LibPipelineConvert retained their own source. ApprovalFacet and SiloGettersFacet have no externally linked libraries. No protocol parameters were changed.

LibraryPrevious ImplementationNew ImplementationUsed By
LibSilo0x49bfc93e96d467d79fc809c8f6da466f8ebb89750xefa4e6492966228a7af3d5d9045bd9c9e5dc72bfClaimFacet, ConvertFacet, PipelineConvertFacet, SiloFacet
LibTokenSilo0xe47c1d275ceb1554ce802a0755cc679294f1ae810xf2a0e7fb0e9b1189b14274418e4ac78ae449b4edClaimFacet, ConvertFacet, PipelineConvertFacet, SiloFacet
LibConvert0xd10b907e2f8f452c4d43848a4f632a00eff9530b0x71e8ab0a025c0b96d64c34759880e6ba2ba0baa0ConvertFacet
LibPipelineConvert0x9b42c78bd19fdf3cf3b3c16c9184e1169bf2c7aa0xa4a2d1e394faac3e60297a55cdceeb38c0b6ca18ConvertFacet, PipelineConvertFacet

Function Changes