Synthetixio / simulation

Agent-based model of the proposed stablecoin.
24 stars 18 forks source link

Marketplayer Sell Function is Incorrect #38

Open 0xdomrom opened 7 years ago

0xdomrom commented 7 years ago

Currently the _sell_quoted function uses the lowest price to calculate the quantity to place a buy order for. This will lead to errors as multiple order prices can be filled, leading leftover of the quoted quantity.

eg. Market = NOM_FIAT quantity = 100 buying FIAT using 100 NOM lowest ask is 50@1.1 So the player attempts to buy 100/1.1 fiat ~ 90.9 order is partially filled: player get 50 fiat, left with 45 NOM, still has to buy 40.9 FIAT next lowest ask is 50@1.5 Player attempts to buy 40.9 FIAT, but only has 45 NOM, can only afford 30FIAT order will fail. player left with 50 FIAT, 45 NOM even though they wanted to use all NOM