Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Remove Safe Liquidity (#19)
Browse files Browse the repository at this point in the history
Related to cowprotocol/solver-rewards#157 and this slack discussion. Removes safe liquidity field from query and order rewards schema.
  • Loading branch information
bh2smith authored Dec 12, 2022
1 parent 2d22e81 commit 790c5f9
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/fetch/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_content(self, max_retries: int = 3) -> Optional[Any]:
return None

@classmethod
async def fetch_many(
async def fetch_many( # pylint: disable=too-many-locals
cls, missing_rows: list[dict[str, str]], max_retries: int = 3
) -> tuple[list[FoundContent], list[NotFoundContent]]:
"""Async AppData Fetching"""
Expand Down Expand Up @@ -97,6 +97,9 @@ async def fetch_many(
break
except asyncio.TimeoutError:
attempts += 1
except aiohttp.ContentTypeError as err:
log.warning(f"failed to parse response {response} with {err}")
attempts += 1

if not content:
total_attempts = previous_attempts + max_retries
Expand Down
1 change: 0 additions & 1 deletion src/models/order_rewards_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def from_pdf_to_dune_records(cls, rewards_df: DataFrame) -> list[dict[str, Any]]
"data": {
"surplus_fee": str(row["surplus_fee"]),
"amount": float(row["amount"]),
"safe_liquidity": row["safe_liquidity"],
},
}
for row in rewards_df.to_dict(orient="records")
Expand Down
8 changes: 1 addition & 7 deletions src/sql/orderbook/order_rewards.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ select concat('0x', encode(trade_hashes.order_uid, 'hex')) as order_uid,
concat('0x', encode(solver, 'hex')) as solver,
concat('0x', encode(tx_hash, 'hex')) as tx_hash,
coalesce(surplus_fee, 0)::text as surplus_fee,
coalesce(reward, 0.0) as amount,
-- An order is a liquidity order if and only if reward is null.
-- A liquidity order is safe if and only if its fee_amount is > 0
case
when reward is null and fee_amount > 0 then True
when reward is null and fee_amount = 0 then False
end as safe_liquidity
coalesce(reward, 0.0) as amount
from trade_hashes
left outer join order_execution o
on trade_hashes.order_uid = o.order_uid
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_fetch_orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_get_order_rewards(self):
],
"surplus_fee": ["0", "0"],
"amount": [40.70410, 39.00522],
"safe_liquidity": [None, None],
}
)

Expand Down
4 changes: 0 additions & 4 deletions tests/unit/test_order_rewards_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def test_order_rewards_transformation(self):
"tx_hash": ["0x71", "0x72", "0x73"],
"surplus_fee": [12345678910111213, 0, 0],
"amount": [40.70410, 39.00522, 0],
"safe_liquidity": [None, True, False],
}
)

Expand All @@ -27,7 +26,6 @@ def test_order_rewards_transformation(self):
"data": {
"surplus_fee": "12345678910111213",
"amount": 40.70410,
"safe_liquidity": None,
},
},
{
Expand All @@ -37,7 +35,6 @@ def test_order_rewards_transformation(self):
"data": {
"surplus_fee": "0",
"amount": 39.00522,
"safe_liquidity": True,
},
},
{
Expand All @@ -47,7 +44,6 @@ def test_order_rewards_transformation(self):
"data": {
"surplus_fee": "0",
"amount": 0.0,
"safe_liquidity": False,
},
},
],
Expand Down

0 comments on commit 790c5f9

Please sign in to comment.