-
Notifications
You must be signed in to change notification settings - Fork 51
sdk: add calculateClientCollateralSize #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
sdk/src/math/collateral.ts
Outdated
| ).value.amount | ||
| ); | ||
| return marketsAccount.markets.reduce((collateralVaultAmount, market) => { | ||
| return collateralVaultAmount.sub(market.amm.totalFee.div(new BN(2))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this trying to calculate how much of the collateral is the users? If so i don't think you need to divide by two
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xbigz mentioned in Discord that the collateral wallet holds the user collateral plus the insurance fund, which is equal to the amount of half of the total fees collected (as in calculateInsuranceFundSize ). So this was my attempt to 'back out' the insurance portion from the collateral balance.
I may have misunderstood him though - @0xbigz thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the fees are owned by the users, so I think it's safe to subtract the entire totalFee (the exchange can use them in various ways)
|
HI guys, I've pushed an update that removes the division. No conflicts it looks like, but a security check failed. |
New helper method I am using in the discord bot, figured it might make sense to add directly to the SDK.