Skip to content

Problem#3 #6

@artman325

Description

@artman325

Average price are not available from beginning of deploy.
we using oracle like in Openzeppelin SimpleOracle (contract acummulate price the only once in period(24h) and calculate average price by formula
averagePrice = (cumulativePriceLast - cumulativePrevious)/windowSize;
and cumulativePrice = (reserve1/reserve2)*timeElapsed;

case#1:

-contract deployed
-adding initial liquidity
-make update() 
cumulativeLast changes,but average price seems is not correct, because time_passed = 0;cumulativePrevious equal 0
cumulativePriceLast = 100*100/0
averagePrice = (0-0)/86400 = 0

seems happens smth unexpected

case#2:

-contract deployed
-adding initial liquidity
-make forceSync for uniswapPair contract
- pass several seconds(50 sec) and make update() 
cumulativeLast changes,but average price seems is not correct, because time_passed = too low like several seconds i.e. 50; cumulativePrevious equal 0;
cumulativePriceLast = 100*100/50
averagePrice = (200-0)/86400

seems averagePrice are wrong

case#3:

-contract deployed
-adding initial liquidity
-make forceSync for uniswapPair contract
- Users do couple of swaps But admin didn't call update(), so price will be freeze

And seems we can not do it in user transactin swap, because price will changed and can't do atomic swap

Summary:
Please provide an exmaple workflow how contract will work using average price in calculation

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions