mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 01:08:07 +00:00
fix(exchanges): restore type-check safety net and repair dead balance guards
tsconfig compiled docs/ (vendored ccxt samples) and @types/react was missing,
so 269 tsc errors buried the real ones. Scoping the project and adding the
missing type packages left 42 genuine errors in src/, which exposed two bugs:
- lighter: assertSpotBalance's buy branch and createOrder's spot-sell guard
compared the {available, wallet} object against a number, so both guards
were dead. Introduce SpotAssetBalance with a precomputed 'effective' field
(Extract Class) and route all three call sites through it.
- offset-maker: the below-min-sell branch logged 'skip sell' but pushed the
SELL order anyway, and pushed a possibly-null price. Both branches now
match their working sibling.
Also: widen LighterOrder's is_ask/reduce_only to BooleanFlag (the wire format
flags.ts already parses), extract sellableBase (Extract Function, 3 copies),
delete two scripts importing a module that does not exist, add a typecheck
script. tsc --noEmit: 269 -> 0 errors; 218 tests still pass.
This commit is contained in:
@@ -50,6 +50,6 @@ describe("LighterSigner", () => {
|
||||
expect(signed.txHash.length).toBeGreaterThan(0);
|
||||
}
|
||||
expect(typeof signed.signature).toBe("string");
|
||||
expect(signed.signature.length).toBeGreaterThan(0);
|
||||
expect(signed.signature?.length ?? 0).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,10 +60,11 @@ describe("MakerPointsEngine defense-mode REST polling", () => {
|
||||
price: "100",
|
||||
origQty: "1",
|
||||
executedQty: "0",
|
||||
stopPrice: "0",
|
||||
time: Date.now(),
|
||||
updateTime: Date.now(),
|
||||
reduceOnly: "false",
|
||||
closePosition: "false",
|
||||
reduceOnly: false,
|
||||
closePosition: false,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ describe("order-coordinator", () => {
|
||||
timers,
|
||||
pending,
|
||||
"BUY",
|
||||
100,
|
||||
"100",
|
||||
1,
|
||||
log,
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user