Skip to content

Commit

Permalink
remove quote test
Browse files Browse the repository at this point in the history
- remove fee test
- remove test of fee test
- remove quoting endpoint from orderbook api
  • Loading branch information
fhenneke committed Dec 19, 2023
1 parent f02246f commit ac2bded
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 188 deletions.
66 changes: 0 additions & 66 deletions src/apis/orderbookapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,69 +58,3 @@ def get_solver_competition_data(self, tx_hash: str) -> Optional[dict[str, Any]]:
)
return None
return solver_competition_data

def get_quote(self, trade: Trade) -> Optional[Trade]:
"""
Given a trade, compute buy_amount, sell_amount, and fee_amount of the trade
as proposed by our quoting infrastructure.
"""

if trade.data.is_sell_order:
kind = "sell"
limit_amount_name = "sellAmountBeforeFee"
executed_amount = trade.execution.sell_amount
else:
kind = "buy"
limit_amount_name = "buyAmountAfterFee"
executed_amount = trade.execution.buy_amount

request_dict = {
"sellToken": trade.data.sell_token,
"buyToken": trade.data.buy_token,
"receiver": "0x0000000000000000000000000000000000000000",
"appData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"partiallyFillable": False,
"sellTokenBalance": "erc20",
"buyTokenBalance": "erc20",
"from": "0x0000000000000000000000000000000000000000",
"priceQuality": "optimal",
"signingScheme": "eip712",
"onchainOrder": False,
"kind": kind,
limit_amount_name: str(executed_amount),
}
prod_endpoint_url = f"{PROD_BASE_URL}quote"

try:
quote_response = requests.post(
prod_endpoint_url,
headers=header,
json=request_dict,
timeout=REQUEST_TIMEOUT,
)
except requests.RequestException as err:
self.logger.warning(
f"Fee quote failed. Request: {request_dict}, error: {err}"
)
return None

if quote_response.status_code != SUCCESS_CODE:
error_response_json = json.loads(quote_response.content)
self.logger.warning(
f"Error {error_response_json['errorType']},"
+ f"{error_response_json['description']} while getting quote for trade {trade}"
)
return None

quote_json = json.loads(quote_response.text)
self.logger.debug("Quote received: %s", quote_json)

quote_buy_amount = int(quote_json["quote"]["buyAmount"])
quote_sell_amount = int(quote_json["quote"]["sellAmount"])
quote_fee_amount = int(quote_json["quote"]["feeAmount"])

quote_execution = OrderExecution(
quote_buy_amount, quote_sell_amount, quote_fee_amount
)

return Trade(trade.data, quote_execution)
3 changes: 0 additions & 3 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
COST_COVERAGE_ABSOLUTE_DEVIATION_ETH = 0.01
COST_COVERAGE_RELATIVE_DEVIATION = 0.50

# fee quote test
FEE_RELATIVE_DEVIATION_FLAG = 1.0

# reference solver test
SOLVER_TIME_LIMIT = 20

Expand Down
4 changes: 0 additions & 4 deletions src/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from src.monitoring_tests.solver_competition_surplus_test import (
SolverCompetitionSurplusTest,
)
from src.monitoring_tests.partially_fillable_fee_quote_test import (
PartialFillFeeQuoteTest,
)
from src.monitoring_tests.partially_fillable_cost_coverage_test import (
PartialFillCostCoverageTest,
)
Expand Down Expand Up @@ -46,7 +43,6 @@ def main() -> None:
tests = [
SolverCompetitionSurplusTest(),
ReferenceSolverSurplusTest(),
PartialFillFeeQuoteTest(),
PartialFillCostCoverageTest(),
CostCoveragePerSolverTest(),
MEVBlockerRefundsMonitoringTest(),
Expand Down
101 changes: 0 additions & 101 deletions src/monitoring_tests/partially_fillable_fee_quote_test.py

This file was deleted.

15 changes: 1 addition & 14 deletions tests/e2e/fee_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,13 @@
"""

import unittest
from src.monitoring_tests.partially_fillable_fee_quote_test import (
PartialFillFeeQuoteTest,
)

from src.monitoring_tests.partially_fillable_cost_coverage_test import (
PartialFillCostCoverageTest,
)


class TestFees(unittest.TestCase):
def test_fee_quote(self):
fee_test = PartialFillFeeQuoteTest()
tx_hash = "0xf467a6a01f61fa608c1bc116e2f4f4df1b95461827b1e7700c1d36628875feab"
self.assertTrue(fee_test.run(tx_hash))
# buy order:
tx_hash = "0x8e9f98cabf9b6ff4e001eda5efacfd70590a60bd03a499d8b02130b67b208eb1"
self.assertTrue(fee_test.run(tx_hash))
# small executed amount:
tx_hash = "0xda857a0db563dae564b09febb683fff6150628c1706afc9ebd961c194ca29c5e"
self.assertTrue(fee_test.run(tx_hash))

def test_cost_coverage(self):
fee_test = PartialFillCostCoverageTest()
tx_hash = "0xf467a6a01f61fa608c1bc116e2f4f4df1b95461827b1e7700c1d36628875feab"
Expand Down

0 comments on commit ac2bded

Please sign in to comment.