> For the complete documentation index, see [llms.txt](https://adrena.gitbook.io/adrena/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adrena.gitbook.io/adrena/reports/01-10-2024-be-custody-internal-state-for-assets-reports-too-much-locked-collateral.md).

# 01/10/2024 - BE - Custody internal state for \`Assets\` reports too much locked collateral

### What

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.\ <br>

<figure><img src="/files/tIvXMCTR57FgWxEl7s8t" alt=""><figcaption></figcaption></figure>

### Impact

Every-time someone increase an existing positon, the `Assets.locked` of the `Custody` drifts up compared to `positionAccounting.lockedAmount`.&#x20;

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 (<br>

### Resolution

* 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

### Details

**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**](https://dao.adrena.xyz/dao/AdrenaDAO/proposal/J6bGmeSpTU5A7XMuTDeZ4RCznoAyC5JGYYitybEuVvgU)
