Skip to content

Commit

Permalink
Merge pull request #13 from primitivefinance/fix/invariant-approx
Browse files Browse the repository at this point in the history
fix(add-invariant-last): adds invariant last to new invariant calc
  • Loading branch information
Alexangelj committed Oct 10, 2021
2 parents 3187216 + 7caeddb commit 9796474
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ReplicationMath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ export function getRiskyGivenStableApproximation(
reserveStable: number,
strike: number,
sigma: number,
tau: number
tau: number,
invariantLast = 0
): number {
const func = reserveRisky => getInvariantApproximation(reserveRisky, reserveStable, strike, sigma, tau)
const func = reserveRisky => getInvariantApproximation(reserveRisky, reserveStable, strike, sigma, tau, invariantLast)

const MAX_RISKY = 1
let optimalDeltaOut: number
Expand All @@ -76,9 +77,10 @@ export function getInvariantApproximation(
reserveStable: number,
strike: number,
sigma: number,
tau: number
tau: number,
invariantLast = 0
): number {
return reserveStable - getStableGivenRiskyApproximation(reserveRisky, strike, sigma, tau)
return reserveStable - getStableGivenRiskyApproximation(reserveRisky, strike, sigma, tau, invariantLast)
}

// ===== Precise math =====
Expand Down

0 comments on commit 9796474

Please sign in to comment.