Skip to content

Commit

Permalink
return BN for profit share calcultation
Browse files Browse the repository at this point in the history
  • Loading branch information
ChesterSim committed Aug 7, 2023
1 parent 3fa3bc1 commit b1d80c0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ts/sdk/src/accounts/vaultDepositorAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ export class VaultDepositorAccount extends VaultsProgramAccount<
}

/**
* Calculates the proportion of a depositor's funds that will be paid as profit share fees.
* Calculates the percentage of a depositor's funds that will be paid as profit share fees.
*
* @param vaultProfitShare Vault's profit share fee
* @param depositorEquity Vault depositor's net deposit value
*/
calcProfitShareFeesProportion(
vaultProfitShare: BN,
depositorEquity: BN
): number {
calcProfitShareFeesProportion(vaultProfitShare: BN, depositorEquity: BN): BN {
const accountData = this.accountSubscriber.getAccountAndSlot().data;

const profit = depositorEquity
Expand All @@ -61,8 +58,9 @@ export class VaultDepositorAccount extends VaultsProgramAccount<
const profitShareAmount = profit
.mul(vaultProfitShare)
.div(PERCENTAGE_PRECISION);
const profitShareProportion =
profitShareAmount.toNumber() / depositorEquity.toNumber();
const profitShareProportion = profitShareAmount
.mul(PERCENTAGE_PRECISION)
.div(depositorEquity);

return profitShareProportion;
}
Expand Down

0 comments on commit b1d80c0

Please sign in to comment.