Skip to content

Commit

Permalink
Cleanup routerhandler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
barak manos committed Jun 5, 2024
1 parent 5554986 commit 80939fe
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions fastlane_bot/helpers/routehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,17 @@ def generate_flashloan_struct(self, trade_instructions_objects: List[TradeInstru
self.ConfigObj.WBTC_ADDRESS,
self.ConfigObj.LINK_ADDRESS
]:
return [
{
"platformId": 2,
"sourceTokens": [self.wrapped_gas_token_to_native(source_token)],
"sourceAmounts": [abs(trade_instructions_objects[0].amtin_wei)]
}
]
platform_id = 2
else:
return [
{
"platformId": 7,
"sourceTokens": [source_token],
"sourceAmounts": [abs(trade_instructions_objects[0].amtin_wei)]
}
]
platform_id = 7

return [
{
"platformId": platform_id,
"sourceTokens": [source_token],
"sourceAmounts": [abs(trade_instructions_objects[0].amtin_wei)]
}
]

def native_gas_token_to_wrapped(self, tkn: str):
"""
Expand All @@ -348,16 +344,6 @@ def native_gas_token_to_wrapped(self, tkn: str):
"""
return self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS if tkn == self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS else tkn

def wrapped_gas_token_to_native(self, tkn: str):
"""
This function returns the native gas token address if the input token is the wrapped gas token, otherwise it returns the input token address.
:param tkn: str
The token address
returns: str
The token address, converted to native gas token if the input was the wrapped gas token
"""
return self.ConfigObj.NATIVE_GAS_TOKEN_ADDRESS if tkn == self.ConfigObj.WRAPPED_GAS_TOKEN_ADDRESS else tkn

@staticmethod
def _get_trade_dicts_from_objects(trade_instructions: List[TradeInstruction]) -> List[Dict[str, Any]]:
return [
Expand Down

0 comments on commit 80939fe

Please sign in to comment.