Skip to content

Commit

Permalink
Address remaining comments from curve trades PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nebolax committed Mar 30, 2023
1 parent 57aa61a commit def7723
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions rotkehlchen/chain/ethereum/modules/curve/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ def _read_curve_asset(
asset_address: Optional[ChecksumEvmAddress],
chain_id: ChainID,
) -> Optional[Asset]:
"""A thin wrapper that turns asset address into an asset object"""
"""
A thin wrapper that turns asset address into an asset object.
Object returned here is a pure Asset (not a resolved CryptoAsset) since it is meant only for
comparison with other assets. And to compare with other assets there is no need to resolve.
"""
if asset_address is None:
return None

Expand Down Expand Up @@ -308,10 +313,10 @@ def _decode_curve_trades(self, context: DecoderContext) -> DecodingOutput:
# Curve swap router logs route (a list of addresses) that was used. Route consists of
# 9 elements. Consider X a number of pools that was used. Then the structure can be
# described in the following way:
# At 0 index: Address of token in
# At 0 index: Address of the sold token (token that goes in the router)
# From 1 to X indices: Addresses of pools that were used
# At 1+X index: Address of token out
# From 2+X to 8 indices: Unused elements (zero addresses)
# At X + 1 index: Address of the bought token (token that comes from the router)
# From X + 2 to 8 indices: Unused elements (zero addresses)
# Here we read only addresses of token in and token out.
sold_token_address = hex_or_bytes_to_address(context.tx_log.data[:32])
for i in range(1, 9): # Starting from 1 because at 0 is `sold_token_address`
Expand Down
6 changes: 4 additions & 2 deletions rotkehlchen/globaldb/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def globaldb_get_general_cache_keys_and_values_like(
"""
Function to read globaldb cache.
Returns all pairs key-value where key starts with the provided `key_parts`.
`key_parts` should not contain neither `%` nor `.` symbols.
key_parts should contain neither the "%" nor the "." symbol.
"""
cache_key = compute_cache_key(key_parts)
return cursor.execute(
Expand Down Expand Up @@ -136,7 +137,8 @@ def globaldb_delete_general_cache_like(
) -> None:
"""
Function to delete globaldb cache. Deletes all the values that start with key.
`key_parts` should not contain neither `%` nor `.` symbols.
key_parts should contain neither the "%" nor the "." symbol.
"""
cache_key = compute_cache_key(key_parts)
write_cursor.execute('DELETE FROM general_cache WHERE key LIKE ?', (f'{cache_key}%',))

0 comments on commit def7723

Please sign in to comment.