Shouldn't fees be excluded when estimating the price impact?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with estimate_price_impact in uniswap/uniswap.py at the lines linked in the issue, then compare its calculation with the Uniswap Interface references. Check how the fee parameter and get_price_input affect the estimate. Done means determining whether fees should be separated and, if so, defining the accurate price impact calculation and updating its behavior accordingly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In https://github.com/uniswap-python/uniswap-python/blob/master/uniswap/uniswap.py#L1879:L1920 estimate_price_impact function the price impact is estimated by operating on the current raw price of the pool and the output of get_price_input call.
- Do I understand correctly that the
get_price_inputincludes the change resulting from both the price impact and the fee? - If so, why isn't the fee excluded from the price impact to provide the accurate price impact?
In Uniswap Interface, they refer to this 'accurate price impact' as 'realised', and indeed it gets calculated by taking the price impact, and subtracting the fees from it:
export function computeRealizedPriceImpact(trade: Trade<Currency, Currency, TradeType>): Percent {
const realizedLpFeePercent = computeRealizedLPFeePercent(trade)
return trade.priceImpact.subtract(realizedLpFeePercent)
}
Where trade.priceImpact is the calculated price impact, and the computeRealizedLPFeePercent is a function that gets the total fees of the trade expressed as a percentage.
Note, that Uniswap Interface uses the Auto Router, which could carry out a single trade through different swaps, meaning that there would be multiple fees that need to be taken into account, hence the computeRealizedLPFeePercent() function that calculates these. However in case of uniswap-python library we don't use the Auto Router (at the time of writing this), hence we could simply subtract the fixed percentage fee which we know as it is passed as a parameter of estimate_price_impact function. Ie.:
fee_percentage = fee / 1000000
return float((price_small - price_amount) / price_small - fee_percentage )
Hence:
- Would this, in a sense, be a more accurate estimation of the actual price impact?
- Naturally, the resulting swap output the user receives from a trade would include the impact of both the fees and the price impact.
- Still, wouldn't it be more clear to explicitly separate the estimation of the price impact from estimating fees, and have the user check for these separately if they wanted to? It makes sense to me, seeing that this is what the Uniswap Interface does.
- Lingua principale
- Python
- Stelle
- 1k
- Fork
- 373
- Merge medio
- 4g 11h
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di uniswap-python/uniswap-python
-
Broken links in the docsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
uniswap-python/uniswap-python#487 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
uniswap-python/uniswap-python#415 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 20/100
uniswap-python/uniswap-python#405 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
uniswap-python/uniswap-python#404 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
uniswap-python/uniswap-python#380 · 13 commenti · 6 reazioni ·
Tutte le issue di uniswap-python/uniswap-python
Issue simili
-
Agentic
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Imbad0202/academic-research-skills#979 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
reflex-dev/reflex#7561 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
prometheus-community/ansible#906 · 2 commenti ·