01/10/2024 - BE - Custody internal state for `Assets` reports too much locked collateral
Previous12/10/2024 - BE - Borrow fees reset on position increaseNext27/09/2024 - BE - Missing accounts reload during fee distribution
Last updated
When a user increase a long or short position, the whole size of the position is re-added to the Asset struct, we keep another value LockedAmount in the Custody that is increased properly.

Every-time someone increase an existing positon, the Assets.locked of the Custody drifts up compared to positionAccounting.lockedAmount.
In term of impact, this affected the borrow rate calculation: users may have paid a higher borrow rate on positions.
Overall this very marginally increased the AUM due to taking more fees (
Add integration tests that triggers the issue
Fix the calculation in the code: add only the increased size and not the whole amount in the code.
Add an one time patch IX to the program that doctors the existing values of Assets.Locked, aligning them with the correct LockedAmount kept in the stats
Add related integration tests that check the patch IX
issue found: Gaius & Jaki (initial report), Corto and Orex investigation afterward issue fix: Orex and Corto patch in: Release/6 - Adrena Program v1.0.5 on 01/30/2024 proposal url: https://dao.adrena.xyz/dao/AdrenaDAO/proposal/J6bGmeSpTU5A7XMuTDeZ4RCznoAyC5JGYYitybEuVvgU
Last updated