docs: Address comments, make clippy happy
This commit is contained in:
@@ -12,12 +12,11 @@ use crate::encoding::{
|
|||||||
strategy_encoder::{StrategyEncoder, StrategyEncoderRegistry},
|
strategy_encoder::{StrategyEncoder, StrategyEncoderRegistry},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Contains all supported strategies to encode a solution.
|
/// Contains all supported strategies to encode a solution.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `strategies` - A hashmap containing the name of the strategy as a key and the strategy
|
/// * `strategies` - A hashmap containing the name of the strategy as a key and the strategy encoder
|
||||||
/// encoder as a value.
|
/// as a value.
|
||||||
pub struct EVMStrategyEncoderRegistry {
|
pub struct EVMStrategyEncoderRegistry {
|
||||||
strategies: HashMap<String, Box<dyn StrategyEncoder>>,
|
strategies: HashMap<String, Box<dyn StrategyEncoder>>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ pub trait EVMStrategyEncoder: StrategyEncoder {
|
|||||||
/// # Fields
|
/// # Fields
|
||||||
///
|
///
|
||||||
/// * `swap_encoder_registry`: SwapEncoderRegistry, containing all possible swap encoders
|
/// * `swap_encoder_registry`: SwapEncoderRegistry, containing all possible swap encoders
|
||||||
/// * `permit2`: Permit2, the object containing necessary information for managing permit2 operations
|
/// * `permit2`: Permit2, the object containing necessary information for managing permit2
|
||||||
|
/// operations
|
||||||
/// * `selector`: String, the selector for the swap function in the router contract
|
/// * `selector`: String, the selector for the swap function in the router contract
|
||||||
pub struct SplitSwapStrategyEncoder {
|
pub struct SplitSwapStrategyEncoder {
|
||||||
swap_encoder_registry: SwapEncoderRegistry,
|
swap_encoder_registry: SwapEncoderRegistry,
|
||||||
@@ -219,8 +220,8 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This strategy encoder is used for solutions that are sent directly to the pool.
|
/// This strategy encoder is used for solutions that are sent directly to the executor, bypassing
|
||||||
/// Only one solution with one swap is supported.
|
/// the router. Only one solution with one swap is supported.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
///
|
///
|
||||||
@@ -243,7 +244,7 @@ impl StrategyEncoder for ExecutorStrategyEncoder {
|
|||||||
) -> Result<(Vec<u8>, Bytes), EncodingError> {
|
) -> Result<(Vec<u8>, Bytes), EncodingError> {
|
||||||
let router_address = solution.router_address.ok_or_else(|| {
|
let router_address = solution.router_address.ok_or_else(|| {
|
||||||
EncodingError::InvalidInput(
|
EncodingError::InvalidInput(
|
||||||
"Router address is required for straight to pool solutions".to_string(),
|
"Router address is required for straight-to-executor solutions".to_string(),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use crate::encoding::{
|
|||||||
swap_encoder::SwapEncoder,
|
swap_encoder::SwapEncoder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Encodes a swap on a Uniswap V2 pool through the given executor address.
|
/// Encodes a swap on a Uniswap V2 pool through the given executor address.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
@@ -151,7 +150,7 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encodes a swap on a Balancer pool through the given executor address.
|
/// Encodes a swap on a Balancer V2 pool through the given executor address.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ pub struct Solution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents an action to be performed on the native token either before or after the swap.
|
/// Represents an action to be performed on the native token either before or after the swap.
|
||||||
|
///
|
||||||
/// `Wrap` means that the native token will be wrapped before the first swap, and `Unwrap`
|
/// `Wrap` means that the native token will be wrapped before the first swap, and `Unwrap`
|
||||||
/// means that the native token will be unwrapped after the last swap, before being sent to the
|
/// means that the native token will be unwrapped after the last swap, before being sent to the
|
||||||
/// receiver.
|
/// receiver.
|
||||||
@@ -60,23 +61,22 @@ pub struct Swap {
|
|||||||
pub split: f64,
|
pub split: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a transaction to be executed on the Ethereum network.
|
/// Represents a transaction to be executed.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `to`: Address of the contract to call with the calldata
|
/// * `to`: Address of the contract to call with the calldata
|
||||||
/// * `value`: ETH value to be sent with the transaction.
|
/// * `value`: Native token value to be sent with the transaction.
|
||||||
/// * `data`: Encoded calldata for the transaction.
|
/// * `data`: Encoded calldata for the transaction.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Transaction {
|
pub struct Transaction {
|
||||||
// Address of the contract to call with the calldata
|
// Address of the contract to call with the calldata
|
||||||
pub to: Bytes,
|
pub to: Bytes,
|
||||||
// ETH value to be sent with the transaction.
|
// Native token value to be sent with the transaction.
|
||||||
pub value: BigUint,
|
pub value: BigUint,
|
||||||
// Encoded calldata for the transaction.
|
// Encoded calldata for the transaction.
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Represents necessary attributes for encoding an order.
|
/// Represents necessary attributes for encoding an order.
|
||||||
pub struct EncodingContext {
|
pub struct EncodingContext {
|
||||||
pub receiver: Bytes,
|
pub receiver: Bytes,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ pub trait StrategyEncoder {
|
|||||||
fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>>;
|
fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Contains the supported strategies to encode a solution, and chooses the best strategy to encode
|
/// Contains the supported strategies to encode a solution, and chooses the best strategy to encode
|
||||||
/// a solution based on the solution's attributes.
|
/// a solution based on the solution's attributes.
|
||||||
pub trait StrategyEncoderRegistry {
|
pub trait StrategyEncoderRegistry {
|
||||||
|
|||||||
Reference in New Issue
Block a user