18 lines
655 B
TypeScript
18 lines
655 B
TypeScript
/**
|
|
* Withdrawal-based referral commissions: base amount = gains from main-account predictions only.
|
|
*/
|
|
|
|
/** Net profit from settled main-account real-money predictions (won/lost/neutral). */
|
|
export function computeCommissionableWithdrawalBase(input: {
|
|
netMainPredictionProfit: bigint;
|
|
alreadyCommissionedGains: bigint;
|
|
withdrawalAmount: bigint;
|
|
}): bigint {
|
|
const remaining =
|
|
input.netMainPredictionProfit > input.alreadyCommissionedGains
|
|
? input.netMainPredictionProfit - input.alreadyCommissionedGains
|
|
: 0n;
|
|
if (remaining <= 0n) return 0n;
|
|
return remaining < input.withdrawalAmount ? remaining : input.withdrawalAmount;
|
|
}
|