diff --git a/benchmark/core/trade/impl.py b/benchmark/core/trade/impl.py index 2dcc9d20..797beb03 100644 --- a/benchmark/core/trade/impl.py +++ b/benchmark/core/trade/impl.py @@ -76,7 +76,9 @@ def tradeBySourceAmountFunc(x, y, z, A, B): temp4 = mulDivC(temp1, temp1, factor) temp5 = mulDivC(temp3, A, factor) - return mulDivF(temp2, temp3 // factor, add(temp4, temp5)) + if temp4 + temp5 <= MAX_UINT256: + return mulDivF(temp2, temp3 // factor, temp4 + temp5) + return temp2 // add(A, mulDivC(temp1, temp1, temp3)) # # x * z ^ 2 diff --git a/benchmark/resources/match/SpecialMatch.json b/benchmark/resources/match/SpecialMatch.json index df8c712a..ab7fb2e9 100644 --- a/benchmark/resources/match/SpecialMatch.json +++ b/benchmark/resources/match/SpecialMatch.json @@ -871,5 +871,97 @@ } ] } + }, + { + "method": "matchBySourceAmount", + "amount": "10000000000000000000000", + "orders": [ + { + "liquidity": "9694677352470453892074", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + }, + { + "liquidity": "96946773524704538920743", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + }, + { + "liquidity": "969467735247045389207437", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + }, + { + "liquidity": "9694677352470453892074378", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + }, + { + "liquidity": "96946773524704538920743789", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + } + ], + "actions": { + "Fast": [ + { + "id": "0", + "input": "164298820", + "output": "9694677346078191181485" + }, + { + "id": "1", + "input": "1642988201", + "output": "96946773494115245173215" + }, + { + "id": "2", + "input": "16429882019", + "output": "969467735241152451806436" + }, + { + "id": "3", + "input": "164298820191", + "output": "9694677352444857851397115" + }, + { + "id": "4", + "input": "1642988201917", + "output": "96946773524681911847310712" + } + ], + "Best": [ + { + "id": "0", + "input": "164298820", + "output": "9694677346078191181485" + }, + { + "id": "1", + "input": "1642988201", + "output": "96946773494115245173215" + }, + { + "id": "2", + "input": "16429882019", + "output": "969467735241152451806436" + }, + { + "id": "3", + "input": "164298820191", + "output": "9694677352444857851397115" + }, + { + "id": "4", + "input": "1642988201917", + "output": "96946773524681911847310712" + } + ] + } } ] \ No newline at end of file diff --git a/benchmark/resources/trade/ExtremeSrcTrade.json b/benchmark/resources/trade/ExtremeSrcTrade.json index e44003e3..32397499 100644 --- a/benchmark/resources/trade/ExtremeSrcTrade.json +++ b/benchmark/resources/trade/ExtremeSrcTrade.json @@ -7152,5 +7152,19 @@ "impl": "11263526807791440437174508207861", "spec": "11263526807791494477914130651426" } + }, + { + "method": "tradeBySourceAmount", + "amount": "15120357940", + "order": { + "liquidity": "969467735247045389207437", + "lowestRate": "33333333333333.01391180980424255864136284799315035343170166015625", + "highestRate": "198019801980197.408654344705869476683801622129976749420166015625", + "marginalRate": "104452559155538.8882958589671163947507815520699425817338168004935" + }, + "output": { + "impl": "924248818871126217204242", + "spec": "924248818871128843570750.388118986304" + } } ] \ No newline at end of file