mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 18:41:36 +00:00
5f7e26b052
Fixes #1201
24 lines
513 B
TypeScript
24 lines
513 B
TypeScript
import { pn } from './prettyNumbers';
|
|
|
|
interface computeSatsProps {
|
|
amount: number;
|
|
premium?: number;
|
|
fee: number;
|
|
routingBudget?: number;
|
|
rate?: number;
|
|
}
|
|
const computeSats = ({
|
|
amount,
|
|
premium = 0,
|
|
fee,
|
|
routingBudget = 0,
|
|
rate = 1,
|
|
}: computeSatsProps): string | undefined => {
|
|
const rateWithPremium = rate + premium / 100;
|
|
let sats = (amount / rateWithPremium) * 100000000;
|
|
sats = sats * (1 - fee) * (1 - routingBudget);
|
|
return pn(Math.round(sats));
|
|
};
|
|
|
|
export default computeSats;
|