forked from Astrea-Payouts/astrea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfees.test.ts
More file actions
23 lines (19 loc) · 803 Bytes
/
Copy pathfees.test.ts
File metadata and controls
23 lines (19 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { describe, expect, it } from "vitest";
import { amountToFundForExactNet, netAmountAfterFee } from "./fees";
describe("fees", () => {
it("deducts the fixed 0.3% protocol fee (ADR-005 K01 result: 12 -> 11.964)", () => {
expect(netAmountAfterFee(12)).toBeCloseTo(11.964, 7);
});
it("stacks the platform fee on top of the protocol fee", () => {
expect(netAmountAfterFee(100, 0.02)).toBeCloseTo(97.7, 7);
});
it("computes the fund amount that nets exactly the target prize", () => {
const funded = amountToFundForExactNet(500);
expect(netAmountAfterFee(funded)).toBeCloseTo(500, 7);
});
it("round-trips through both directions", () => {
const gross = 250;
const net = netAmountAfterFee(gross, 0.01);
expect(amountToFundForExactNet(net, 0.01)).toBeCloseTo(gross, 7);
});
});