solana-labs / perpetuals

Solana perpetuals reference implementation
Other
66 stars 36 forks source link

Update interest calculation for collateral custodies #25

Closed askibin closed 11 months ago

mzs-dev commented 11 months ago

Don't think this fixes the issue with misappropriated computation of interest. The proposed change here: https://github.com/askibin/perpetuals-fork/blob/86c3f3498019807a89df9f54ab85be76008812dc/programs/perpetuals/src/state/custody.rs#L497-L498 does account for proper tracking of interest accrued on collateral custody in case of shorts or virtual asset positions. However we're computing the wrong interest amount in case of shorts here: https://github.com/askibin/perpetuals-fork/blob/86c3f3498019807a89df9f54ab85be76008812dc/programs/perpetuals/src/state/custody.rs#L444 and updating the stats here: https://github.com/askibin/perpetuals-fork/blob/86c3f3498019807a89df9f54ab85be76008812dc/programs/perpetuals/src/state/custody.rs#L453 Which is included in pool aum calculations here: https://github.com/solana-labs/perpetuals/blob/2b715801f5531c7d75800acfe1e9f25c18d20700/programs/perpetuals/src/state/pool.rs#L756-L799

askibin commented 11 months ago

agree, the interest was counted twice for shorts/virtual, in both custody and collateral_custody, updated

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
perpetuals ❌ Failed (Inspect) Aug 1, 2023 9:44pm