Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix LO swapInfo.AmountIn in case take fee in takerAsset (#644)" #658

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pkg/source/limitorder/pool_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ func (p *PoolSimulator) calcAmountWithSwapInfo(swapSide SwapSide, tokenAmountIn
SwapSide: swapSide,
AmountIn: tokenAmountIn.Amount.String(),
}
totalFilledTakingAmountWei := big.NewInt(0)
isFulfillAmountIn := false
totalFeeAmountWei := new(big.Int)

Expand Down Expand Up @@ -277,7 +276,6 @@ func (p *PoolSimulator) calcAmountWithSwapInfo(swapSide SwapSide, tokenAmountIn
swapInfo.FilledOrders = append(swapInfo.FilledOrders, filledOrderInfo)
isFulfillAmountIn = true
addFilledMakingAmount(filledMakingAmountByMaker, order.Maker, filledMakingAmountWei)
totalFilledTakingAmountWei.Add(totalFilledTakingAmountWei, filledTakingAmountWei)

// Currently, when Aggregator finds route and returns some orders and sends them to the smart contract to execute.
// We will often meet edge cases that these orders can be fulfilled by a trading bot or taker on Aggregator.
Expand Down Expand Up @@ -320,12 +318,10 @@ func (p *PoolSimulator) calcAmountWithSwapInfo(swapSide SwapSide, tokenAmountIn
filledOrderInfo := newFilledOrderInfo(order, remainingTakingAmountWei.String(), remainingMakingAmountWei.String(), feeAmountWeiByOrder.String())
swapInfo.FilledOrders = append(swapInfo.FilledOrders, filledOrderInfo)
addFilledMakingAmount(filledMakingAmountByMaker, order.Maker, remainingMakingAmountWei)
totalFilledTakingAmountWei.Add(totalFilledTakingAmountWei, remainingTakingAmountWei)
}
if !isFulfillAmountIn {
return nil, SwapInfo{}, nil, ErrCannotFulfillAmountIn
}
swapInfo.AmountIn = totalFilledTakingAmountWei.String()
return totalAmountOutWei, swapInfo, totalFeeAmountWei, nil
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/source/limitorder/pool_simulator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ func TestPool_CalcAmountOut_v2(t *testing.T) {
assert.Equal(t, tc.expAmountOut, res.TokenAmountOut.Amount.String())

si := res.SwapInfo.(SwapInfo)
assert.Equal(t, bignumber.NewBig10(tc.amountIn), bignumber.NewBig10(si.AmountIn))
oid := make([]int64, 0, len(si.FilledOrders))
oinfo := ""
for _, o := range si.FilledOrders {
Expand Down Expand Up @@ -1080,7 +1079,6 @@ func TestPool_UpdateBalance(t *testing.T) {
assert.Equal(t, swap.expAmountOut, res.TokenAmountOut.Amount.String())

si := res.SwapInfo.(SwapInfo)
assert.Equal(t, bignumber.NewBig10(swap.amountIn), bignumber.NewBig10(si.AmountIn))
oid := make([]int64, 0, len(si.FilledOrders))
oinfo := ""
for _, o := range si.FilledOrders {
Expand Down Expand Up @@ -1231,7 +1229,6 @@ func TestPool_Inventory(t *testing.T) {
assert.Equal(t, swap.expAmountOut, res.TokenAmountOut.Amount.String())

si := res.SwapInfo.(SwapInfo)
assert.Equal(t, bignumber.NewBig10(swap.amountIn), bignumber.NewBig10(si.AmountIn))
oid := make([]int64, 0, len(si.FilledOrders))
oinfo := ""
for _, o := range si.FilledOrders {
Expand Down Expand Up @@ -1366,7 +1363,6 @@ func TestPool_CalcAmountOut_TakerAssetFee(t *testing.T) {
}
assert.Equal(t, tc.expOrderIds, oid, oinfo)
fmt.Println(oinfo)
fmt.Println("--", si.AmountIn)
})
}
}
Loading