File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/portfolio-contract/tools Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ const replaceOrInit = <K, V>(
3737 map . set ( key , callback ( old , key , exists ) ) ;
3838} ;
3939
40+ /**
41+ * Reduce a value by a natural number of basis points, rounding the result down
42+ * (e.g., 1 bp of 10k is exactly 1, so subtracting 1 bp from any value up to 10k
43+ * reduces it by a full unit).
44+ */
45+ export const applyHaircut = ( n : bigint , bps : bigint ) =>
46+ ( n * ( 10000n - bps ) ) / 10000n ;
47+
4048// eslint-disable-next-line @typescript-eslint/no-unused-vars
4149const trace = makeTracer ( 'solve' ) ;
4250
@@ -453,7 +461,7 @@ export const rebalanceMinCostFlowSteps = async (
453461 // HACK: subtract 1n to avoid rounding errors in Noble per
454462 // https://github.com/Agoric/agoric-private/issues/415
455463 const usdnOut =
456- ( BigInt ( flow ) * ( 10000n - BigInt ( edge . variableFee ) ) ) / 10000n - 1n ;
464+ applyHaircut ( BigInt ( flow ) , BigInt ( edge . variableFee ) ) - 1n ;
457465 details = { detail : { usdnOut } } ;
458466 break ;
459467 }
You can’t perform that action at this time.
0 commit comments