penumbra-zone / penumbra

Penumbra is a fully private proof-of-stake network and decentralized exchange for the Cosmos ecosystem.
https://penumbra.zone
Apache License 2.0
357 stars 287 forks source link

dex_utils: implement v3 approximations #4112

Open erwanor opened 3 months ago

erwanor commented 3 months ago

Is your feature request related to a problem? Please describe. Currently, our implementation of replicated market makers only support approximating the x*y=k curve over an "infinite" liquidity range. As pointed by @hdevalence, this means that the position distribution is skewed at the extremes of this range:

 ID                                                                State     Fee        Sell Price             Reserves
 plpid1t0yx3cn2fp72s7gy09ra4zrvx7nacc2ftpp85d5m7aqhffglv03suncr9a  opened  42bps        10penumbra         740.967746gn
 plpid1xt2vdazq9j4wpmpe29cj2rc2768k0hta9a32sk0j0h640l2c4gmsnswvp8  opened  42bps         5penumbra         243.814939gn
 plpid1a5z05wwsvrc4hu9v4azw76d6m84837lvtvrtulgv6czlxpraxjmqkr9lwz  opened  42bps  3.333334penumbra         189.311849gn
(snip)
 plpid1vn7jydp9cx9vf7kuk7qcc7ff7qv3v4ftj3v3eujdn8rmytffuqas0ce9ca  opened  42bps        2.800001gn    21.351881penumbra
 plpid15jn60qg5s590kzu25qr7nxpe8ujkyg5h0mlsee94aa6ev205pv9sw2sxj0  opened  42bps        2.900001gn    20.256501penumbra
 plpid1m5e8xchzl49td9s356ggge2e7e2vv3v4k7kywzssz2jtnc0ekktsnv5hj3  opened  42bps               3gn  1164.486839penumbra

It would be more capital efficient and just plain better to add a UniV3 concentrated liquidity replication that takes a price, an inventory, and a range, and builds the replicated portfolio corresponding to that curve.

erwanor commented 1 month ago

I will pick this up next, @TalDerei could be a fun one to pair on.

TalDerei commented 1 month ago

I will pick this up next, @TalDerei could be a fun one to pair on.

that would be really great!

erwanor commented 3 weeks ago

Not much progress on this yet, other than we sketched the PVF and we'll pair on building a julia notebook early next week