Skip to content

Commit e8a0d57

Browse files
committed
Revert incorrect simulation loop formula
TEST RESULTS PROVED: - OLD: remainingUSDC = tokens * F * price → 16,283 tokens, 6.51x (CORRECT) - NEW: remainingUSDC = tokens * F → 6.6M tokens, 2659x (EXPONENTIAL, WRONG) Root cause: Simulation uses simplified leverage model, not exact protocol mechanics. - Simplified: borrow F * (token value) in USDC → geometric series (1-F^n)/(1-F) - Protocol: borrow F * (collateral sets) in USDC → different mechanics Keeping: - Runway validation (prevents debt > collateral) - Improved loop formula (old returned Infinity) - Protocol documentation (helps integrators understand real mechanics) Clarified comments to distinguish simulation model from protocol mechanics.
1 parent ba97f37 commit e8a0d57

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ export class ForecastLeverageSDK {
185185
const tokensThisLoop = remainingUSDC / params.currentPrice;
186186
totalTokens += tokensThisLoop;
187187

188-
// Protocol lends F per $1 of collateral (1 YES + 1 NO = $1)
189-
// CRITICAL: Each token pair is worth $1, NOT token price
190-
remainingUSDC = tokensThisLoop * leverageParams.F;
188+
// Simplified leverage model: borrow F * (token value) in USDC
189+
// This creates convergent geometric series: capital * (1-F^n)/(1-F)
190+
remainingUSDC = tokensThisLoop * leverageParams.F * params.currentPrice;
191191

192192
if (remainingUSDC < 1) break;
193193
}

0 commit comments

Comments
 (0)