Skip to content

Commit

Permalink
Fixes broken tests due to custom fees
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewcasale committed Aug 15, 2023
1 parent 78fc667 commit bca8da0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 39 deletions.
94 changes: 58 additions & 36 deletions resources/NBTest/NBTest_037_Exchanges.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 33,
"id": "c539b26e",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.254090Z",
"start_time": "2023-07-03T21:13:19.248999Z"
"end_time": "2023-08-15T18:22:17.531620Z",
"start_time": "2023-08-15T18:22:17.517077Z"
}
},
"outputs": [
Expand All @@ -22,7 +22,6 @@
"SushiswapV2 v0.0.1 (2023-07-03)\n",
"CarbonV1 v0.0.1 (2023-07-03)\n",
"BancorV3 v0.0.1 (2023-07-03)\n",
"imported m, np, pd, plt, os, sys, decimal; defined iseq, raises, require\n",
"Version = 3-b2.2 [requirements >= 3.0 is met]\n"
]
}
Expand Down Expand Up @@ -55,12 +54,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 34,
"id": "9c8a3b4d",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.255126Z",
"start_time": "2023-07-03T21:13:19.249653Z"
"end_time": "2023-08-15T18:22:17.538531Z",
"start_time": "2023-08-15T18:22:17.519799Z"
}
},
"outputs": [],
Expand All @@ -71,20 +70,21 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 35,
"id": "cbe1ab01",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.260477Z",
"start_time": "2023-07-03T21:13:19.255727Z"
"end_time": "2023-08-15T18:22:17.539582Z",
"start_time": "2023-08-15T18:22:17.524015Z"
}
},
"outputs": [],
"source": [
"mocked_contract = Mock()\n",
"mocked_contract.functions.token0.return_value.call.return_value = 'token0'\n",
"mocked_contract.functions.token1.return_value.call.return_value = 'token1'\n",
"mocked_contract.functions.fee.return_value.call.return_value = 3000"
"mocked_contract.functions.fee.return_value.call.return_value = 3000\n",
"mocked_contract.caller.tradingFeePPM.return_value = 2000"
]
},
{
Expand All @@ -97,12 +97,12 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 36,
"id": "e2347c4c",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.263232Z",
"start_time": "2023-07-03T21:13:19.261536Z"
"end_time": "2023-08-15T18:22:17.542183Z",
"start_time": "2023-08-15T18:22:17.526669Z"
}
},
"outputs": [],
Expand All @@ -123,12 +123,12 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 37,
"id": "43c80791",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.313981Z",
"start_time": "2023-07-03T21:13:19.272427Z"
"end_time": "2023-08-15T18:22:17.542551Z",
"start_time": "2023-08-15T18:22:17.530303Z"
}
},
"outputs": [],
Expand All @@ -149,12 +149,12 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 38,
"id": "1765d5ff",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.316204Z",
"start_time": "2023-07-03T21:13:19.282571Z"
"end_time": "2023-08-15T18:22:17.552299Z",
"start_time": "2023-08-15T18:22:17.532938Z"
}
},
"outputs": [],
Expand All @@ -175,12 +175,12 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 39,
"id": "05e931be",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.324994Z",
"start_time": "2023-07-03T21:13:19.291726Z"
"end_time": "2023-08-15T18:22:17.552404Z",
"start_time": "2023-08-15T18:22:17.535505Z"
}
},
"outputs": [],
Expand All @@ -201,19 +201,30 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 40,
"id": "69f70b07",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.325514Z",
"start_time": "2023-07-03T21:13:19.297889Z"
"end_time": "2023-08-15T18:22:17.552784Z",
"start_time": "2023-08-15T18:22:17.538580Z"
}
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fee: 2000\n"
]
}
],
"source": [
"from fastlane_bot.data.abi import CARBON_CONTROLLER_ABI_WITH_FEES\n",
"\n",
"carbon_v1_exchange = CarbonV1()\n",
"assert (carbon_v1_exchange.get_abi() == CARBON_CONTROLLER_ABI)\n",
"assert (carbon_v1_exchange.get_fee('', mocked_contract) == ('0.002', 0.002))\n",
"\n",
"assert (carbon_v1_exchange.get_abi() == CARBON_CONTROLLER_ABI_WITH_FEES)\n",
"assert (carbon_v1_exchange.get_fee('', mocked_contract) == ('2000', 0.002))\n",
"assert (carbon_v1_exchange.get_tkn0('', mocked_contract, setup_data['carbon_v1_event_update']) == setup_data['carbon_v1_event_update']['args']['token0'])"
]
},
Expand All @@ -227,15 +238,27 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 41,
"id": "62910e09",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.325661Z",
"start_time": "2023-07-03T21:13:19.304311Z"
"end_time": "2023-08-15T18:22:17.553225Z",
"start_time": "2023-08-15T18:22:17.548712Z"
}
},
"outputs": [],
"outputs": [
{
"ename": "AssertionError",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mAssertionError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[41], line 2\u001B[0m\n\u001B[1;32m 1\u001B[0m carbon_v1_exchange \u001B[38;5;241m=\u001B[39m CarbonV1()\n\u001B[0;32m----> 2\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m (carbon_v1_exchange\u001B[38;5;241m.\u001B[39mget_abi() \u001B[38;5;241m==\u001B[39m CARBON_CONTROLLER_ABI)\n\u001B[1;32m 3\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m (carbon_v1_exchange\u001B[38;5;241m.\u001B[39mget_fee(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m'\u001B[39m, mocked_contract) \u001B[38;5;241m==\u001B[39m (\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m0.002\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;241m0.002\u001B[39m))\n\u001B[1;32m 4\u001B[0m \u001B[38;5;28;01massert\u001B[39;00m (carbon_v1_exchange\u001B[38;5;241m.\u001B[39mget_tkn0(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m'\u001B[39m, mocked_contract, setup_data[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcarbon_v1_event_create\u001B[39m\u001B[38;5;124m'\u001B[39m]) \u001B[38;5;241m==\u001B[39m setup_data[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcarbon_v1_event_create\u001B[39m\u001B[38;5;124m'\u001B[39m][\u001B[38;5;124m'\u001B[39m\u001B[38;5;124margs\u001B[39m\u001B[38;5;124m'\u001B[39m][\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtoken0\u001B[39m\u001B[38;5;124m'\u001B[39m])\n",
"\u001B[0;31mAssertionError\u001B[0m: "
]
}
],
"source": [
"carbon_v1_exchange = CarbonV1()\n",
"assert (carbon_v1_exchange.get_abi() == CARBON_CONTROLLER_ABI)\n",
Expand All @@ -253,12 +276,11 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "cce5df61",
"metadata": {
"ExecuteTime": {
"end_time": "2023-07-03T21:13:19.325765Z",
"start_time": "2023-07-03T21:13:19.306952Z"
"start_time": "2023-08-15T18:22:17.551906Z"
}
},
"outputs": [],
Expand Down
12 changes: 9 additions & 3 deletions resources/NBTest/NBTest_037_Exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.13.1
# jupytext_version: 1.14.7
# kernelspec:
# display_name: Python 3
# language: python
Expand Down Expand Up @@ -46,6 +46,7 @@
mocked_contract.functions.token0.return_value.call.return_value = 'token0'
mocked_contract.functions.token1.return_value.call.return_value = 'token1'
mocked_contract.functions.fee.return_value.call.return_value = 3000
mocked_contract.caller.tradingFeePPM.return_value = 2000

# ## test_uniswap_v2_exchange

Expand Down Expand Up @@ -77,10 +78,15 @@

# ## test_carbon_v1_exchange_update

# +
from fastlane_bot.data.abi import CARBON_CONTROLLER_ABI_WITH_FEES

carbon_v1_exchange = CarbonV1()
assert (carbon_v1_exchange.get_abi() == CARBON_CONTROLLER_ABI)
assert (carbon_v1_exchange.get_fee('', mocked_contract) == ('0.002', 0.002))

assert (carbon_v1_exchange.get_abi() == CARBON_CONTROLLER_ABI_WITH_FEES)
assert (carbon_v1_exchange.get_fee('', mocked_contract) == ('2000', 0.002))
assert (carbon_v1_exchange.get_tkn0('', mocked_contract, setup_data['carbon_v1_event_update']) == setup_data['carbon_v1_event_update']['args']['token0'])
# -

# ## test_carbon_v1_exchange_create

Expand Down

0 comments on commit bca8da0

Please sign in to comment.