Submitted by jonah1005
Pool calculates the amount to be minted based on token_amount and sparta_amount of the Pool. However, since token_amount in the pool would not decrease when users mint Synth, its always cheaper to mint synth than swap the tokens.
The synthetics would be really hard to be on peg. Or, there would be a flash-loan attacker to win all the arbitrage space.
In Pools mint synth, The synth amount is calculated at L:232
which is the same as swapping base to token at L:287
However, while swapping tokens decrease pools token, mint just mint it out of the air.
Heres a POC:
Swap sparta to token for ten times
Mint Synth for ten times
The Pool was initialized with 10000:10000 in both cases. While the first case(swap token) gets 4744.4059 and the second case gets 6223.758.
The debt should be considered in the AMM pool so I recommend to maintain a debt variable in the Pool and use tokenAmount - debt when the Pool calculates the token price. Heres some idea of it:
verifyfirst (Spartan) confirmed:
