Skip to content

Commit

Permalink
decrease token out amount from reserve (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
tien7668 authored Dec 17, 2024
1 parent 6854e8e commit 4ee6cdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/source/camelot/pool_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ func (p *PoolSimulator) CalcAmountOut(param pool.CalcAmountOutParams) (*pool.Cal
func (p *PoolSimulator) UpdateBalance(params pool.UpdateBalanceParams) {
if strings.EqualFold(params.TokenAmountIn.Token, p.Info.Tokens[0]) {
p.Info.Reserves[0] = new(big.Int).Sub(new(big.Int).Add(p.Info.Reserves[0], params.TokenAmountIn.Amount), params.Fee.Amount)
p.Info.Reserves[1] = new(big.Int).Add(p.Info.Reserves[1], params.TokenAmountOut.Amount)
p.Info.Reserves[1] = new(big.Int).Sub(p.Info.Reserves[1], params.TokenAmountOut.Amount)
} else {
p.Info.Reserves[0] = new(big.Int).Add(p.Info.Reserves[0], params.TokenAmountOut.Amount)
p.Info.Reserves[0] = new(big.Int).Sub(p.Info.Reserves[0], params.TokenAmountOut.Amount)
p.Info.Reserves[1] = new(big.Int).Sub(new(big.Int).Add(p.Info.Reserves[1], params.TokenAmountIn.Amount), params.Fee.Amount)
}
}
Expand Down

0 comments on commit 4ee6cdf

Please sign in to comment.