kabu_execution_multicaller/pool_opcodes_encoder/
mod.rs

1use crate::pool_abi_encoder::ProtocolAbiSwapEncoderTrait;
2pub use crate::pool_opcodes_encoder::swap_opcodes_encoders::MulticallerOpcodesPayload;
3use alloy_primitives::Address;
4pub use curve::CurveSwapOpcodesEncoder;
5use eyre::{eyre, Result};
6use kabu_types_blockchain::MulticallerCalls;
7use kabu_types_entities::{Pool, SwapAmountType};
8pub use steth::StEthSwapEncoder;
9pub use swap_opcodes_encoders::ProtocolSwapOpcodesEncoderV2;
10pub use uniswap2::UniswapV2SwapOpcodesEncoder;
11pub use uniswap3::UniswapV3SwapOpcodesEncoder;
12pub use wsteth::WstEthSwapEncoder;
13
14mod curve;
15mod steth;
16mod uniswap2;
17mod uniswap3;
18mod wsteth;
19
20mod swap_opcodes_encoders;
21
22pub trait SwapOpcodesEncoderTrait: Send + Sync + 'static {
23    #[allow(clippy::too_many_arguments)]
24    fn encode_swap_in_amount_provided(
25        &self,
26        swap_opcodes: &mut MulticallerCalls,
27        abi_encoder: &dyn ProtocolAbiSwapEncoderTrait,
28        token_from_address: Address,
29        token_to_address: Address,
30        amount_in: SwapAmountType,
31        cur_pool: &dyn Pool,
32        next_pool: Option<&dyn Pool>,
33        payload: MulticallerOpcodesPayload,
34        multicaller_address: Address,
35    ) -> Result<()>;
36
37    #[allow(clippy::too_many_arguments)]
38    fn encode_swap_out_amount_provided(
39        &self,
40        swap_opcodes: &mut MulticallerCalls,
41        abi_encoder: &dyn ProtocolAbiSwapEncoderTrait,
42        token_from_address: Address,
43        token_to_address: Address,
44        amount_out: SwapAmountType,
45        cur_pool: &dyn Pool,
46        next_pool: Option<&dyn Pool>,
47        payload: MulticallerOpcodesPayload,
48        multicaller_address: Address,
49    ) -> Result<()>;
50
51    #[allow(clippy::too_many_arguments)]
52    fn encode_flash_swap_in_amount_provided(
53        &self,
54        _swap_opcodes: &mut MulticallerCalls,
55        _abi_encoder: &dyn ProtocolAbiSwapEncoderTrait,
56        _token_from_address: Address,
57        _token_to_address: Address,
58        _amount_in: SwapAmountType,
59        _flash_pool: &dyn Pool,
60        _prev_pool: Option<&dyn Pool>,
61        _payload: MulticallerOpcodesPayload,
62        _multicaller_address: Address,
63    ) -> Result<()> {
64        Err(eyre!("NOT_IMPLEMENTED"))
65    }
66
67    #[allow(clippy::too_many_arguments)]
68    fn encode_flash_swap_out_amount_provided(
69        &self,
70        _swap_opcodes: &mut MulticallerCalls,
71        _abi_encoder: &dyn ProtocolAbiSwapEncoderTrait,
72        _token_from_address: Address,
73        _token_to_address: Address,
74        _amount_out: SwapAmountType,
75        _flash_pool: &dyn Pool,
76        _next_pool: Option<&dyn Pool>,
77        _payload: MulticallerOpcodesPayload,
78        _multicaller_address: Address,
79    ) -> Result<()> {
80        Err(eyre!("NOT_IMPLEMENTED"))
81    }
82}