perpetuals
perpetuals copied to clipboard
Issue with Interest fee calculations
@askibin The interest amount being calcualted in usd value using position.size_usd is not appropriate. https://github.com/solana-labs/perpetuals/blob/30b9f8c344df14568475fa621dea1db7af15a6b3/programs/perpetuals/src/state/custody.rs#L312
Ideally Interest should be charged on the locked_amount assets that are collateralising the postions for pnl payoff and accounted accordingly.
Also, the collective position handling invokes the get_interest_amount_usd() function under the context of the worng custody. For isntance: https://github.com/solana-labs/perpetuals/blob/85dc9ed43718590d1008c6bdd209d3c0091298ae/programs/perpetuals/src/instructions/open_position.rs#L346 Invokes: https://github.com/solana-labs/perpetuals/blob/85dc9ed43718590d1008c6bdd209d3c0091298ae/programs/perpetuals/src/state/custody.rs#L444
To solve this issue we propose a seperate "market" state once https://github.com/solana-labs/perpetuals/issues/16#issue-1770458393 is solved
why do you think it is the wrong custody? a trader borrows the trade token not stablecoin so interest should be calculated on "custody" and not "collateral_custody"
Only true for longs... Trader does not borrow the trade token, he borrows/locks the same token as the collateral token. For example, when a trader opens a short position, he brings stable-coin collateral and we should lock the same... Hence to solve for the possibiltiy of a many-many relationship between (position) custody and collateral custody we want to introduce a link-account state known as Market and handle this accordingly
Any update here? Is this actually a current issue?
this was changed to use collateral custody