feat: Add propeller swap encoders
- Add setup for package - Add docs - Add balancer implementation and test - Add CI: - Add setup action - Add test and format CI - Add CD: Publish python package to AWS
This commit is contained in:
33
propeller-swap-encoders/propeller_swap_encoders/balancer.py
Normal file
33
propeller-swap-encoders/propeller_swap_encoders/balancer.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from typing import Any
|
||||
|
||||
from core.encoding.interface import SwapStructEncoder
|
||||
from core.type_aliases import Address
|
||||
from eth_abi.packed import encode_abi_packed
|
||||
from hexbytes import HexBytes
|
||||
|
||||
|
||||
class BalancerSwapStructEncoder(SwapStructEncoder):
|
||||
def encode_swap_struct(
|
||||
self, swap: dict[str, Any], receiver: Address, exact_out: bool, **kwargs
|
||||
) -> bytes:
|
||||
"""
|
||||
Parameters:
|
||||
----------
|
||||
swap
|
||||
The swap to encode
|
||||
receiver
|
||||
The receiver of the buy token
|
||||
exact_out
|
||||
Whether the amount encoded is the exact amount out
|
||||
"""
|
||||
return encode_abi_packed(
|
||||
["address", "address", "bytes32", "address", "bool", "bool"],
|
||||
[
|
||||
swap["sell_token"].address,
|
||||
swap["buy_token"].address,
|
||||
HexBytes(swap["pool_id"]),
|
||||
receiver,
|
||||
exact_out,
|
||||
swap["token_approval_needed"],
|
||||
],
|
||||
)
|
||||
Reference in New Issue
Block a user