balancer-v2-monorepo icon indicating copy to clipboard operation
balancer-v2-monorepo copied to clipboard

Derivation of stable spot price

Open xenide opened this issue 1 year ago • 1 comments

I'm trying to ascertain the correctness of the function that calculates the stable spot price. Referring to the code here.

  1. how is this equation derived?
  2. why is that S (sum of balances) is 0?

xenide avatar Dec 09 '24 00:12 xenide

paging @nventuro, could I trouble you take a quick look at this?

xenide avatar Dec 09 '24 01:12 xenide

Hey @xenide,

We've never really used this code in production, and it's been 4 years since its implementation. The spot price is the slope of the invariant function evaluated at the current pool balances, so I assume the formula comes from deriving the implicit invariant function for stable pools. I can't really assure it's correctness at this point though.

jubeira avatar Aug 15 '25 13:08 jubeira