Skip to content

Problem#2 #5

@artman325

Description

@artman325

Admin can add more liquidity but price shouldnt grow down more than priceDrop from average price.
Because of admin havent reserve token and can only mint(claim) traded token contract will swap part of traded tokens to reserve tokens and then will add all to liquidity (without remainder).
this results in case than available traded tokens(10% price grow) are not fully used

for example.
put (nodejs)

rTraded = 100;
rReserve = 100; 
averagePrice = 0.8;
rTraded_new = Math.sqrt(rTraded*rReserve/averagePrice*(1-priceDrop)); // 106.06601717798213
//require(rTraded_new > rTraded)
//tradedToswap - it's a max that admin can add to liquidity to be sure that price will drop not more then `priceDrop` value
//so contract will exchange part of this tokens to reservetokens and add all both parts to liquidity
incomingTradedToken = rTraded_new-rTraded;
r3 = Math.sqrt((rTraded + incomingTradedToken)*(rTraded)) - rTraded;
// doSwapOnUniswap r3 to reserve
tradedToswap = r3;
reserveObtain = (tradedToswap*rReserve)/(rTraded+tradedToswap);
// 
tradedToLiquidity = incomingTradedToken-r3;
reserveToLiquidity = reserveObtain;
//reserves will be
rTraded = rTraded+tradedToLiquidity; //103.07765998262624
rReserve = rReserve-reserveToLiquidity; //97.09835434146468
// was 100
// max can be 106.06601717798213
// result is 103.07765998262624

Summary. Should admin use all available tokens to add liquidity?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions