kabu_types_entities/
mock_pool.rs1use crate::required_state::RequiredState;
2use crate::{Pool, PoolAbiEncoder, PoolClass, PoolId, PoolProtocol, PreswapRequirement, SwapDirection};
3use alloy_primitives::{Address, U256};
4use eyre::ErrReport;
5use eyre::Result;
6use kabu_evm_db::KabuDBError;
7use revm::DatabaseRef;
8use std::any::Any;
9
10#[derive(Clone)]
11pub struct MockPool {
12 pub(crate) token0: Address,
13 pub(crate) token1: Address,
14 pub(crate) address: Address,
15}
16
17impl MockPool {
18 pub fn new(token0: Address, token1: Address, address: Address) -> Self {
19 Self { token0, token1, address }
20 }
21}
22
23impl Pool for MockPool {
24 fn as_any<'a>(&self) -> &dyn Any {
25 self
26 }
27
28 fn get_class(&self) -> PoolClass {
29 PoolClass::UniswapV2
30 }
31
32 fn get_protocol(&self) -> PoolProtocol {
33 PoolProtocol::UniswapV2
34 }
35
36 fn get_address(&self) -> PoolId {
37 PoolId::Address(self.address)
38 }
39
40 fn get_pool_id(&self) -> PoolId {
41 PoolId::Address(self.address)
42 }
43
44 fn get_fee(&self) -> U256 {
45 U256::ZERO
46 }
47
48 fn get_tokens(&self) -> Vec<Address> {
49 vec![self.token0, self.token1]
50 }
51
52 fn get_swap_directions(&self) -> Vec<SwapDirection> {
53 vec![(self.token0, self.token1).into(), (self.token1, self.token0).into()]
54 }
55
56 fn calculate_out_amount(
57 &self,
58 db: &dyn DatabaseRef<Error = KabuDBError>,
59 token_address_from: &Address,
60 token_address_to: &Address,
61 in_amount: U256,
62 ) -> Result<(U256, u64), ErrReport> {
63 panic!("Not implemented")
64 }
65
66 fn calculate_in_amount(
67 &self,
68 db: &dyn DatabaseRef<Error = KabuDBError>,
69 token_address_from: &Address,
70 token_address_to: &Address,
71 out_amount: U256,
72 ) -> Result<(U256, u64), ErrReport> {
73 panic!("Not implemented")
74 }
75
76 fn can_flash_swap(&self) -> bool {
77 panic!("Not implemented")
78 }
79
80 fn can_calculate_in_amount(&self) -> bool {
81 true
82 }
83
84 fn get_abi_encoder(&self) -> Option<&dyn PoolAbiEncoder> {
85 panic!("Not implemented")
86 }
87
88 fn get_read_only_cell_vec(&self) -> Vec<U256> {
89 Vec::new()
90 }
91
92 fn get_state_required(&self) -> Result<RequiredState> {
93 panic!("Not implemented")
94 }
95
96 fn is_native(&self) -> bool {
97 false
98 }
99
100 fn preswap_requirement(&self) -> PreswapRequirement {
101 PreswapRequirement::Base
102 }
103}